Consider a subcommand sha2
for a program computing a hash on some input. This subcommand allows for an argument that conveys the number of bits for the resulting digest:
App::new(crate_name!())
// some arguments ...
.subcommand(App::new("sha2")
.arg(Arg::new("bits")
.about("Size of the resulting digest")
.possible_values(&["256", "384", "512"])
.default_value("256")
.short('B')))
Is there a way to define a subcommand in terms of this one, say sha2-512
which will act as if I invoked this? (the ellipsis at the end are additional arguments):
binaryname sha2 -B 512 ...
So an invocation of my program like so:
binaryname sha2-512 ...
... should result in:
binaryname sha2 -B 512 ...
while keeping it as DRY as possible.
The version of clap
I am using currently is 3.0.0-beta.2
.
Thanks for your time!