-
Hi, I want to create a group of arguments which spans multiple subcommands. Now, I want to specify that the user has to give exactly one version, independent of the method used. # VALID:
mksw --version-majorminor 1.2 download
mksw download --version-majorminor 1.2
mksw source --version-git-revision 17823b
mksw source --version-majorminor 1.2
# INVALID
mksw source --version-git-revision 17823b --version-majorminor 1.2
mksw --version-majorminor 1.2 source --version-git-revision 17823b
mksw download --version-git-revision 17823b This is the struct I've written so far: /// Set the version to be used
#[derive(Parser)]
struct Args {
/// Version to be built as MAJOR.MINOR
#[arg(long, name="MAJOR.MINOR", global=true)]
version_majorminor: Option<String>,
#[command(subcommand)]
software_provider: SoftwareProvider,
}
/// The way the software should be provided.
#[derive(Subcommand)]
enum SoftwareProvider {
/// Downloads a pre-built binary from the interwebz
Download(),
/// Builds from source
Source {
/// Exact git revision to be built
///
/// Can be used instead of --version-majorminor
#[arg(long)]
version_git_revision: Option<String>
}
} I am not sure how to carry on, I assume I have to define an ArgGroup of some sort? But on which struct/argument? Where do I provide its parameters? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
We do not directly support this today and you would need to do that validation yourself. Some somewhat related issues |
Beta Was this translation helpful? Give feedback.
We do not directly support this today and you would need to do that validation yourself.
Some somewhat related issues