Hi, is there a way to alias subcommands, perhaps even with preset configuration?
I'm thinking of something as simple as making tool list equivalent to tool ls,
but also something like tool csv meaning tool list --tabular --separator ";" --colors off.
This would allow turning certain configurations of a subcommand into their own subcommand.
Right now there isn't. If you're on Linux or OSX, shell aliases do exactly that though.
I know, I thought of something internal though, so you could use one subcommand as a preconfigured shortcut to another. Thor does something similar, there you can invoke another :subcommand with a list of set parameters.
I can put this on the issue tracker, but there are a few issues in priority over it so it could be a while. I'll have to play with some implementations to see how it works out.
I'm not super familiar with Thor so I'll into that too. Thanks!
Perhaps it's just a documentation thing, it would only by nice to be able to manually construct ArgMatches nicer, but this is not so super important, as it can be abstracted around. Thank you for your consideration though :clap:
If the alias is known beforehand, you can just route calls for the alias subcommand to the same handler as the other command with arguments. Then also use the AppSettings::Hidden to hide the alias subcommand from the --help message. Just some thoughts.
I've been putting some thought into this, and finally decided on a route to take.
I'll add an App::alias and App::aliases which function as hidden additional subcommands but dispatch to the aliased subcommand. Therefore you only check existence of the aliased command and not all variants.
Once #502 merges I'll put out v2.5.0 on crates.io which contains this feature.
Most helpful comment
I can put this on the issue tracker, but there are a few issues in priority over it so it could be a while. I'll have to play with some implementations to see how it works out.
I'm not super familiar with Thor so I'll into that too. Thanks!