mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
crash! macros
This commit is contained in:
parent
89ad4d6c1b
commit
f6c46024e8
1 changed files with 12 additions and 2 deletions
|
@ -1,3 +1,4 @@
|
|||
#[feature(macro_rules)];
|
||||
#[crate_id(name="basename", vers="1.0.0", author="Jimmy Lu")];
|
||||
|
||||
/*
|
||||
|
@ -19,9 +20,18 @@ use extra::getopts::groups;
|
|||
|
||||
static VERSION: &'static str = "1.0.0";
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! crash(
|
||||
($exitcode:expr, $($args:expr),+) => (
|
||||
{ ::std::os::set_exit_status($exitcode);
|
||||
let _unused = write!(&mut ::std::io::stderr(), $($args),+);
|
||||
return;
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
|
||||
let program = strip_dir(&args[ 0 ].clone());
|
||||
|
||||
//
|
||||
|
@ -34,7 +44,7 @@ fn main() {
|
|||
|
||||
let matches = match groups::getopts(args.tail(), opts) {
|
||||
Ok(m) => m,
|
||||
Err(f) => fail!("Invalid options\n{}", f.to_err_msg())
|
||||
Err(f) => crash!(1, "Invalid options\n{}", f.to_err_msg())
|
||||
};
|
||||
|
||||
if matches.opt_present("help") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue