Allow negative numbers as positional arguments#192
Open
SpecificProtagonist wants to merge 1 commit intogoogle:masterfrom
Open
Allow negative numbers as positional arguments#192SpecificProtagonist wants to merge 1 commit intogoogle:masterfrom
SpecificProtagonist wants to merge 1 commit intogoogle:masterfrom
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 Detailstest 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
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #191
This implementation prioritises recognized flags over positional arguments in the case of ambiguity.
Edit: CLA signed.