reverie-rs / reverie

trace and intercept linux syscalls.
Other
14 stars 5 forks source link

Missing command-line arguments cause panic #52

Closed loganwendholt closed 5 years ago

loganwendholt commented 5 years ago

If reverie is run without all of the required command-line arguments, I would expect to get an error message explaining what was missing, along with a usage message showing me the proper command format.

Instead, reverie currently generates a panic in this scenario, as seen in the following example:

$ ./target/debug/reverie ls
thread 'main' panicked at '[main] tool not specified, default to none', src/libcore/option.rs:1155:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

To remedy this, the clap .required(true) function call could be added to the existing CLI definitions on all the required arguments:

Before:

        .arg(
            Arg::with_name("tool")
                .long("tool")
                .value_name("TOOL")
                .help("choose which tool (/path/to/lib<TOOL>.so) to run, default to none (libnone.so) if not specified. ")
                .takes_value(true),
        )

After:

        .arg(
            Arg::with_name("tool")
                .long("tool")
                .value_name("TOOL")
                .help("choose which tool (/path/to/lib<TOOL>.so) to run, default to none (libnone.so) if not specified. ")
                .takes_value(true)
                .required(true),
        )

Making this change would result in the following behavior when an argument is missing:

$ ./target/debug/reverie ls
error: The following required arguments were not provided:
    --tool <TOOL>

USAGE:
    reverie [FLAGS] [OPTIONS] <PROGRAM> --tool <TOOL> [--] [PROGRAM_ARGS]...

For more information try --help

The new .required(true) line should be added to all required arguments' .arg() entry.

wangbj commented 5 years ago

Thanks, fixed with: 9eba788