-
-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New implementation of rust cli args parsing. (#20698)
The old implementation didn't support two features that the Python implementation does: 1) goal scoping (`pants test --foo` vs `pants test --test-foo`) 2) short flag values without `=` (`-ldebug` vs `-l=debug`) It also did a lot of temporary String allocation. It was also somewhat hard to grok, especially its handling of negation. This new implementation supports the features above, and removes support for adding the negation prefix to short flags (`--no-l`) which we don't support in python, and which doesn't really make sense. It also minimizes String allocation: it only allocates when parsing the args, or when finding a match, but not when comparing option ids to args, which it now does via char iterators. One big difference between this new Rust implementation and the Python one is that the Python parser knows when it encounters a goal on the CLI by looking up strings (that don't start with a dash) in a list of known scopes. This was originally done to avoid confusion with targets, but in practice targets always contain a `/` (we require root-level targets to be prefixed with `//:`) so this isn't necessary, and it simplifies things to detect goal names via regex match.
- Loading branch information
Showing
10 changed files
with
268 additions
and
123 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ authors = ["Pants Build <[email protected]>"] | |
publish = false | ||
|
||
[dependencies] | ||
itertools = { workspace = true } | ||
lazy_static = { workspace = true } | ||
log = { workspace = true } | ||
maplit = { workspace = true } | ||
|
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.