-
-
Notifications
You must be signed in to change notification settings - Fork 649
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move CLI flag extraction into ArgSplitter (#21943)
Previously, for legacy reasons, we had a separate pass for processing flags, while the ArgSplitter dealt with finding goals and specs. This turned out to be not just a code redundancy issue, but it caused a bug: #21930 . This PR cleans up the redundancy and smooths out some ragged legacy edges in the Rust options parser: - Employs uniform terminology: Now all CLI args (specs, goals, flags) are referred to as `args`, while args that set option values are referred to as `flags`. Previously we used `flags` and `args` somewhat interchangeably to refer to the latter, but also `args` to refer to the former. This clears up the ambiguity. - Notably, the `Arg` struct is now called `Flag`, and lives in `flags.rs`. - Gets rid of the previous `Args` struct and its logic, reusing its name to now be just a simple holder of arg strings prior to parsing. - Moves the flag-gathering logic, previously in the old `Args`, into `ArgSplitter`. - Modify tests appropriately. Including removing testing of arbitrary short (`-f`) flags, which happened to work before, even though we only officially support a known small set of such flags (`-v`, `-h`, `-l`). - Regression test for #21930. - Make passthru args an Option, so we can distinguish between `pants ...` and `pants ... --` (i.e., no passthru separator vs a passthru separator with no args after it). --------- Co-authored-by: Huon Wilson <[email protected]>
- Loading branch information
Showing
12 changed files
with
514 additions
and
386 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.