mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-11-29 08:00:27 +00:00
fix(cli): reject conflicting instance selectors (#2887)
This commit is contained in:
@@ -172,7 +172,12 @@ enum OutputFormat {
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
struct InstanceSelectArgs {
|
||||
#[arg(short = 'i', long = "instance-id", help = "the instance id")]
|
||||
#[arg(
|
||||
short = 'i',
|
||||
long = "instance-id",
|
||||
conflicts_with = "name",
|
||||
help = "the instance id"
|
||||
)]
|
||||
id: Option<uuid::Uuid>,
|
||||
|
||||
#[arg(short = 'n', long = "instance-name", help = "the instance name")]
|
||||
@@ -778,6 +783,24 @@ mod tests {
|
||||
use super::*;
|
||||
use easytier::proto::api::instance::PeerConnInfo;
|
||||
|
||||
#[test]
|
||||
fn instance_id_and_name_are_mutually_exclusive() {
|
||||
let id = "12345678-1234-1234-1234-123456789abc";
|
||||
let err = Cli::try_parse_from([
|
||||
"easytier-cli",
|
||||
"--instance-id",
|
||||
id,
|
||||
"--instance-name",
|
||||
"mesh",
|
||||
"peer",
|
||||
])
|
||||
.unwrap_err();
|
||||
assert_eq!(err.kind(), clap::error::ErrorKind::ArgumentConflict);
|
||||
|
||||
Cli::try_parse_from(["easytier-cli", "--instance-id", id, "peer"]).unwrap();
|
||||
Cli::try_parse_from(["easytier-cli", "--instance-name", "mesh", "peer"]).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dns_commands_parse_and_files_preserve_clear_semantics() {
|
||||
let cli = Cli::try_parse_from([
|
||||
|
||||
Reference in New Issue
Block a user