-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow negative numbers as positional arguments #192
base: master
Are you sure you want to change the base?
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Try a test subcommand_example ... ok
test fuchsia_commandline_tools_rubric::keyed_no_equals ... FAILED
test missing_option_value ... FAILED
test options::parsed ... FAILED
test redact_arg_values_produces_errors_with_bad_arguments ... FAILED
failures:
---- fuchsia_commandline_tools_rubric::keyed_no_equals stdout ----
thread 'fuchsia_commandline_tools_rubric::keyed_no_equals' panicked at /home/user/1tmp/argh/argh/tests/lib.rs:928:9:
assertion `left == right` failed
left: "Unrecognized argument: --foo=bar\n"
right: "Unrecognized argument: \"--foo=bar\". Did you mean \"--foo\"?\n"
stack backtrace:
0: rust_begin_unwind
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:652:5
1: core::panicking::panic_fmt
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:72:14
2: core::panicking::assert_failed_inner
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:409:17
3: core::panicking::assert_failed
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:364:5
4: lib::fuchsia_commandline_tools_rubric::keyed_no_equals
at ./tests/lib.rs:928:9
5: lib::fuchsia_commandline_tools_rubric::keyed_no_equals::{{closure}}
at ./tests/lib.rs:922:25
6: core::ops::function::FnOnce::call_once
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5
7: core::ops::function::FnOnce::call_once
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- missing_option_value stdout ----
thread 'missing_option_value' panicked at /home/user/1tmp/argh/argh/tests/lib.rs:436:5:
assertion `left == right` failed
left: "Unrecognized argument: --msg\n"
right: "No value provided for option '--msg'.\n"
stack backtrace:
0: rust_begin_unwind
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:652:5
1: core::panicking::panic_fmt
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:72:14
2: core::panicking::assert_failed_inner
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:409:17
3: core::panicking::assert_failed
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:364:5
4: lib::missing_option_value
at ./tests/lib.rs:436:5
5: lib::missing_option_value::{{closure}}
at ./tests/lib.rs:425:26
6: core::ops::function::FnOnce::call_once
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5
7: core::ops::function::FnOnce::call_once
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- options::parsed stdout ----
thread 'options::parsed' panicked at /home/user/1tmp/argh/argh/tests/lib.rs:457:5:
assertion `left == right` failed
left: "Error parsing option '-n' with value 'x': invalid digit found in string\n"
right: "Unrecognized argument: -n\n"
stack backtrace:
0: rust_begin_unwind
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:652:5
1: core::panicking::panic_fmt
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:72:14
2: core::panicking::assert_failed_inner
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:409:17
3: core::panicking::assert_failed
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:364:5
4: lib::assert_error
at ./tests/lib.rs:457:5
5: lib::options::parsed
at ./tests/lib.rs:475:9
6: lib::options::parsed::{{closure}}
at ./tests/lib.rs:473:16
7: core::ops::function::FnOnce::call_once
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5
8: core::ops::function::FnOnce::call_once
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- redact_arg_values_produces_errors_with_bad_arguments stdout ----
thread 'redact_arg_values_produces_errors_with_bad_arguments' panicked at /home/user/1tmp/argh/argh/tests/lib.rs:1706:5:
assertion `left == right` failed
left: Err(EarlyExit { output: "Unrecognized argument: --n\n", status: Err(()) })
right: Err(EarlyExit { output: "No value provided for option '--n'.\n", status: Err(()) })
stack backtrace:
0: rust_begin_unwind
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:652:5
1: core::panicking::panic_fmt
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:72:14
2: core::panicking::assert_failed_inner
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:409:17
3: core::panicking::assert_failed
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:364:5
4: lib::redact_arg_values_produces_errors_with_bad_arguments
at ./tests/lib.rs:1706:5
5: lib::redact_arg_values_produces_errors_with_bad_arguments::{{closure}}
at ./tests/lib.rs:1697:58
6: core::ops::function::FnOnce::call_once
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5
7: core::ops::function::FnOnce::call_once
at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
failures:
fuchsia_commandline_tools_rubric::keyed_no_equals
missing_option_value
options::parsed
redact_arg_values_produces_errors_with_bad_arguments
test result: FAILED. 69 passed; 4 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.04s
error: test failed, to rerun pass `-p argh --test lib` Alternatively trying this: use argh::FromArgs;
#[derive(FromArgs)]
/// Reach new heights.
struct GoUp {
/// whether or not to jump
#[argh(switch, short = 'j')]
jump: bool,
/// how high to go
#[argh(option)]
height: usize,
/// an optional nickname for the pilot
#[argh(option)]
pilot_nickname: Option<String>,
}
fn main() {
let up: GoUp = argh::from_env();
} bad output:
which should be(if reverted):
but this works:
Footnotes
|
Fixes #191
This implementation prioritises recognized flags over positional arguments in the case of ambiguity.
Edit: CLA signed.