From 0320aa603668b6fea5ef739567dde465c2d66cf8 Mon Sep 17 00:00:00 2001 From: michaeltlombardi <14190564+michaeltlombardi@users.noreply.github.com> Date: Tue, 7 Jul 2026 13:29:17 -0500 Subject: [PATCH] (GH-1393) Rename `--version` to `--required-version` for resource commands Prior to this change, the `dsc resource *` subcommands used the `--version` flag to specify the version requirement for the resource that the command invokes. The option accepts a string which it parses into a `ResourceVersionReq` instance. The name of the option was misleading, as it implied that the user should specify a specific version, like `1.2.3`, when this would actually parse as the version requirement `^1.2.3`, which would match any version `>=1.2.3 <2.0.0`. This change: - Renames the `--version` option to `--required-version` to better reflect the semantics and minimize confusion. - Retains the short option `-v` and aliases the long option `--version` for backward compatibility. - Fixes #1393 --- dsc/src/args.rs | 24 ++++++++++++------------ dsc/src/subcommand.rs | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/dsc/src/args.rs b/dsc/src/args.rs index 4d4622287..71c8773f6 100644 --- a/dsc/src/args.rs +++ b/dsc/src/args.rs @@ -221,8 +221,8 @@ pub enum ResourceSubCommand { all: bool, #[clap(short, long, help = t!("args.resource").to_string())] resource: FullyQualifiedTypeName, - #[clap(short, long, help = t!("args.version").to_string())] - version: Option, + #[clap(short = 'v', long, alias = "version", help = t!("args.version").to_string())] + required_version: Option, #[clap(short, long, help = t!("args.input").to_string(), conflicts_with = "file")] input: Option, #[clap(short = 'f', long, help = t!("args.file").to_string(), conflicts_with = "input")] @@ -234,8 +234,8 @@ pub enum ResourceSubCommand { Set { #[clap(short, long, help = t!("args.resource").to_string())] resource: FullyQualifiedTypeName, - #[clap(short, long, help = t!("args.version").to_string())] - version: Option, + #[clap(short = 'v', long, alias = "version", help = t!("args.version").to_string())] + required_version: Option, #[clap(short, long, help = t!("args.input").to_string(), conflicts_with = "file")] input: Option, #[clap(short = 'f', long, help = t!("args.file").to_string(), conflicts_with = "input")] @@ -249,8 +249,8 @@ pub enum ResourceSubCommand { Test { #[clap(short, long, help = t!("args.resource").to_string())] resource: FullyQualifiedTypeName, - #[clap(short, long, help = t!("args.version").to_string())] - version: Option, + #[clap(short = 'v', long, alias = "version", help = t!("args.version").to_string())] + required_version: Option, #[clap(short, long, help = t!("args.input").to_string(), conflicts_with = "file")] input: Option, #[clap(short = 'f', long, help = t!("args.file").to_string(), conflicts_with = "input")] @@ -262,8 +262,8 @@ pub enum ResourceSubCommand { Delete { #[clap(short, long, help = t!("args.resource").to_string())] resource: FullyQualifiedTypeName, - #[clap(short, long, help = t!("args.version").to_string())] - version: Option, + #[clap(short = 'v', long, alias = "version", help = t!("args.version").to_string())] + required_version: Option, #[clap(short, long, help = t!("args.input").to_string(), conflicts_with = "file")] input: Option, #[clap(short = 'f', long, help = t!("args.file").to_string(), conflicts_with = "input")] @@ -277,8 +277,8 @@ pub enum ResourceSubCommand { Schema { #[clap(short, long, help = t!("args.resource").to_string())] resource: FullyQualifiedTypeName, - #[clap(short, long, help = t!("args.version").to_string())] - version: Option, + #[clap(short = 'v', long, alias = "version", help = t!("args.version").to_string())] + required_version: Option, #[clap(short = 'o', long, help = t!("args.outputFormat").to_string())] output_format: Option, }, @@ -286,8 +286,8 @@ pub enum ResourceSubCommand { Export { #[clap(short, long, help = t!("args.resource").to_string())] resource: FullyQualifiedTypeName, - #[clap(short, long, help = t!("args.version").to_string())] - version: Option, + #[clap(short = 'v', long, alias = "version", help = t!("args.version").to_string())] + required_version: Option, #[clap(short, long, help = t!("args.input").to_string(), conflicts_with = "file")] input: Option, #[clap(short = 'f', long, help = t!("args.file").to_string(), conflicts_with = "input")] diff --git a/dsc/src/subcommand.rs b/dsc/src/subcommand.rs index 1c86d9ae5..483622c80 100644 --- a/dsc/src/subcommand.rs +++ b/dsc/src/subcommand.rs @@ -555,14 +555,14 @@ pub fn resource(subcommand: &ResourceSubCommand, progress_format: ProgressFormat ResourceSubCommand::List { resource_name, adapter_name, description, tags, output_format } => { list_resources(&mut dsc, resource_name, adapter_name.as_ref(), description.as_ref(), tags.as_ref(), output_format.as_ref(), progress_format); }, - ResourceSubCommand::Schema { resource , version, output_format } => { + ResourceSubCommand::Schema { resource, required_version: version, output_format } => { if let Err(err) = dsc.find_resources(&[DiscoveryFilter::new(resource, version.clone(), None)], progress_format) { error!("{}: {err}", t!("subcommand.failedDiscoverResource")); exit(EXIT_DSC_ERROR); } resource_command::schema(&mut dsc, resource, version.as_ref(), output_format.as_ref()); }, - ResourceSubCommand::Export { resource, version, input, file, output_format } => { + ResourceSubCommand::Export { resource, required_version: version, input, file, output_format } => { if let Err(err) = dsc.find_resources(&[DiscoveryFilter::new(resource, version.clone(), None)], progress_format) { error!("{}: {err}", t!("subcommand.failedDiscoverResource")); exit(EXIT_DSC_ERROR); @@ -570,7 +570,7 @@ pub fn resource(subcommand: &ResourceSubCommand, progress_format: ProgressFormat let parsed_input = get_input(input.as_ref(), file.as_ref()); resource_command::export(&mut dsc, resource, version.as_ref(), &parsed_input, output_format.as_ref()); }, - ResourceSubCommand::Get { resource, version, input, file: path, all, output_format } => { + ResourceSubCommand::Get { resource, required_version: version, input, file: path, all, output_format } => { if let Err(err) = dsc.find_resources(&[DiscoveryFilter::new(resource, version.clone(), None)], progress_format) { error!("{}: {err}", t!("subcommand.failedDiscoverResource")); exit(EXIT_DSC_ERROR); @@ -587,7 +587,7 @@ pub fn resource(subcommand: &ResourceSubCommand, progress_format: ProgressFormat resource_command::get(&mut dsc, resource, version.as_ref(), &parsed_input, output_format.as_ref()); } }, - ResourceSubCommand::Set { resource, version, input, file: path, output_format, what_if } => { + ResourceSubCommand::Set { resource, required_version: version, input, file: path, output_format, what_if } => { if let Err(err) = dsc.find_resources(&[DiscoveryFilter::new(resource, version.clone(), None)], progress_format) { error!("{}: {err}", t!("subcommand.failedDiscoverResource")); exit(EXIT_DSC_ERROR); @@ -595,7 +595,7 @@ pub fn resource(subcommand: &ResourceSubCommand, progress_format: ProgressFormat let parsed_input = get_input(input.as_ref(), path.as_ref()); resource_command::set(&mut dsc, resource, version.as_ref(), &parsed_input, output_format.as_ref(), *what_if); }, - ResourceSubCommand::Test { resource, version, input, file: path, output_format } => { + ResourceSubCommand::Test { resource, required_version: version, input, file: path, output_format } => { if let Err(err) = dsc.find_resources(&[DiscoveryFilter::new(resource, version.clone(), None)], progress_format) { error!("{}: {err}", t!("subcommand.failedDiscoverResource")); exit(EXIT_DSC_ERROR); @@ -603,7 +603,7 @@ pub fn resource(subcommand: &ResourceSubCommand, progress_format: ProgressFormat let parsed_input = get_input(input.as_ref(), path.as_ref()); resource_command::test(&mut dsc, resource, version.as_ref(), &parsed_input, output_format.as_ref()); }, - ResourceSubCommand::Delete { resource, version, input, file: path, output_format, what_if } => { + ResourceSubCommand::Delete { resource, required_version: version, input, file: path, output_format, what_if } => { if let Err(err) = dsc.find_resources(&[DiscoveryFilter::new(resource, version.clone(), None)], progress_format) { error!("{}: {err}", t!("subcommand.failedDiscoverResource")); exit(EXIT_DSC_ERROR);