Skip to content

Commit 6f4c969

Browse files
ymgytalessandrod
authored andcommitted
Support --version flag
1 parent 4692fde commit 6f4c969

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/bin/bpf-linker.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::{
1212
use bpf_linker::{Cpu, Linker, LinkerOptions, OptLevel, OutputType};
1313
use clap::{
1414
builder::{PathBufValueParser, TypedValueParser as _},
15+
error::ErrorKind,
1516
Parser,
1617
};
1718
use thiserror::Error;
@@ -80,6 +81,7 @@ fn parent_and_file_name(p: PathBuf) -> anyhow::Result<(PathBuf, PathBuf)> {
8081
}
8182

8283
#[derive(Debug, Parser)]
84+
#[command(version)]
8385
struct CommandLine {
8486
/// LLVM target triple. When not provided, the target is inferred from the inputs
8587
#[clap(long)]
@@ -216,7 +218,16 @@ fn main() -> anyhow::Result<()> {
216218
export,
217219
fatal_errors,
218220
_debug,
219-
} = Parser::try_parse_from(args)?;
221+
} = match Parser::try_parse_from(args) {
222+
Ok(command_line) => command_line,
223+
Err(err) => match err.kind() {
224+
ErrorKind::DisplayHelp | ErrorKind::DisplayVersion => {
225+
print!("{err}");
226+
return Ok(());
227+
}
228+
_ => return Err(err.into()),
229+
},
230+
};
220231

221232
// Configure tracing.
222233
let _guard = {

0 commit comments

Comments
 (0)