Use argv[0] for usage output

Usage messages traditionally use this as it contains the path that the
user provided to run the executable (e.g. `rustfmt` instead of
`/usr/local/bin/rustfmt`).
This commit is contained in:
Steven Fackler 2015-11-19 17:56:37 -08:00
parent f09aa85798
commit d7b331bea7

View file

@ -164,7 +164,7 @@ fn main() {
fn print_usage(opts: &Options, reason: &str) {
let reason = format!("{}\nusage: {} [options] <file>...",
reason,
env::current_exe().unwrap().display());
env::args_os().next().unwrap().to_string_lossy());
println!("{}", opts.usage(&reason));
}