Skip to content

Commit

Permalink
Support --version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ymgyt authored and alessandrod committed Jul 14, 2024
1 parent 4692fde commit 6f4c969
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/bin/bpf-linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::{
use bpf_linker::{Cpu, Linker, LinkerOptions, OptLevel, OutputType};
use clap::{
builder::{PathBufValueParser, TypedValueParser as _},
error::ErrorKind,
Parser,
};
use thiserror::Error;
Expand Down Expand Up @@ -80,6 +81,7 @@ fn parent_and_file_name(p: PathBuf) -> anyhow::Result<(PathBuf, PathBuf)> {
}

#[derive(Debug, Parser)]
#[command(version)]
struct CommandLine {
/// LLVM target triple. When not provided, the target is inferred from the inputs
#[clap(long)]
Expand Down Expand Up @@ -216,7 +218,16 @@ fn main() -> anyhow::Result<()> {
export,
fatal_errors,
_debug,
} = Parser::try_parse_from(args)?;
} = match Parser::try_parse_from(args) {
Ok(command_line) => command_line,
Err(err) => match err.kind() {
ErrorKind::DisplayHelp | ErrorKind::DisplayVersion => {
print!("{err}");
return Ok(());
}
_ => return Err(err.into()),
},
};

// Configure tracing.
let _guard = {
Expand Down

0 comments on commit 6f4c969

Please sign in to comment.