-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Our support for aliases is very naively implemented; it assumes the alias is the first argument in argv. It therefore fails to resolve aliases after global arguments such as `--at-op`. This patch fixes that by using doing an intial parse of the arguments with a modified definition of the CLI passed to `clap`. The modified definition has only global arguments, plus an "external subcommand". That way we can convince `clap` to parse the global arguments for us and give us the alias (or real command) and further arguments back. Thanks to @epage for the suggestion on in clap-rs/clap#3672. The only minor problem is that it doesn't seem possible to tell `clap` to parse global arguments that come after the external subcommand. To work around that, we manually merge any parsed global argument before the alias with any parsed global arguments after it. Closes #292.
- Loading branch information
1 parent
8f5d913
commit b3f9af3
Showing
3 changed files
with
164 additions
and
27 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