yac
/
yacexits
Archived
3
0
Fork 0

made usage output place “Usage:” before the error message.

This commit is contained in:
Emma Tebibyte 2023-03-26 23:59:56 -04:00
parent 348616dddf
commit d2af983f4a
Signed by: emma
GPG Key ID: 6D661C738815E7DD
1 changed files with 7 additions and 2 deletions

View File

@ -1,7 +1,10 @@
mod args;
pub use args::Args;
use crate::exit;
use crate::{
exit,
EX_USAGE,
};
use libc::{
c_int,
@ -48,7 +51,9 @@ pub unsafe extern fn main(argc: c_int, argv: *const *const u8) -> c_int {
exit(71);
});
rust_main(args).unwrap_or_else(|(err, code)| {
libc_eprintln!("{}: {}", argv0, err);
if code == EX_USAGE {
libc_eprintln!("Usage: {} {}", argv0, err);
} else { libc_eprintln!("{}: {}", argv0, err); }
code
}) as _
},