Implementing application-level aliases (like Git's aliases) #3672
-
Hi, I'd like to use I was thinking it could be done by defining any global arguments using the Derive API and then doing something like this:
The question is how I can figure out where in [edited to clarify why I want to use |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
If its of interest, this is how cargo implements aliases. They basically just treat it as an external subcommand (which is supported via the |
Beta Was this translation helpful? Give feedback.
-
There is not currently a way to do this though you could open an issue for us to track argv position. |
Beta Was this translation helpful? Give feedback.
-
If your lookup of aliases is independent of the command line, you could look into replace |
Beta Was this translation helpful? Give feedback.
If its of interest, this is how cargo implements aliases. They basically just treat it as an external subcommand (which is supported via the
#[clap(external_subcommand)]
alias rather than setting it on theCommand
) and do a parse withno_binary_name
set. This won't provide the absolute best errors but its ok. They manually track global arguments rather than having clap do it so they can use them across the different parse invocations.