Skip to content

Commit

Permalink
Support trailing global flags in the native parser. (Cherry-pick of #…
Browse files Browse the repository at this point in the history
…21480) (#21485)

The legacy parser supports having global flags at the end of
the command-line invocation, after all specs.

Now the native parser supports this too.

Fixes #21478

Co-authored-by: Benjy Weinberger <[email protected]>
  • Loading branch information
WorkerPants and benjyw authored Oct 3, 2024
1 parent f809096 commit 49c0b8d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/rust/engine/options/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ impl Args {
});
} else if is_valid_scope_name(&arg_str) {
scope = Scope::Scope(arg_str)
} else {
// The arg is a spec, so revert to global context for any trailing flags.
scope = Scope::Global;
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/rust/engine/options/src/args_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ fn test_bool() {
"scope",
"--no-quuxf",
"--quuxt",
"path/to/target",
"--global-flag",
]);

let assert_bool =
Expand All @@ -91,6 +93,7 @@ fn test_bool() {
assert_bool(false, option_id!(["scope"], "quxf"));
assert_bool(false, option_id!(["scope"], "quuxf"));
assert_bool(true, option_id!(["scope"], "quuxt"));
assert_bool(true, option_id!("global", "flag"));

assert!(args.get_bool(&option_id!("dne")).unwrap().is_none());
assert!(args.get_passthrough_args().is_none());
Expand Down

0 comments on commit 49c0b8d

Please sign in to comment.