Skip to content

Commit

Permalink
Optimize binary name extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
HanabishiRecca committed Jun 4, 2023
1 parent 75ec113 commit a2e0e58
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,15 @@ fn run(
check_updates(find_foreign_packages(ignores, ignore_groups)?)
}

fn get_bin_name() -> Option<String> {
Some(String::from(current_exe().ok()?.file_name()?.to_str()?))
}

pub fn run_app() -> R<()> {
if let Some(config) = read_args(args().skip(1))? {
return run(config);
}

let bin = current_exe().ok();
println!(
include_str!("app/help.in"),
BIN_NAME = get_bin_name().as_deref().unwrap_or(env!("CARGO_BIN_NAME")),
BIN_NAME = (|| bin.as_ref()?.file_name()?.to_str())().unwrap_or(env!("CARGO_BIN_NAME")),
);

Ok(())
Expand Down

0 comments on commit a2e0e58

Please sign in to comment.