From 7947c3bae915412c42c0388e69a361f11e936bb3 Mon Sep 17 00:00:00 2001 From: Yoshihiro OKUMURA Date: Fri, 17 Apr 2026 18:59:18 +0900 Subject: [PATCH] feat(config): simplify list command and add subcommand aliases - config list: remove --long option, always display URL - config list: add ls alias (#[command(alias = "ls")]) - config delete: add rm and remove aliases (#[command(aliases = ["remove", "rm"])]) - README: update config list and config delete examples Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- README.md | 3 ++- src/commands/config.rs | 10 +++------- src/commands/config_subcommand.rs | 7 +++---- src/main.rs | 4 ++-- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 7f2091b..34b3789 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ List registered remote hosts. ```shell mdrs config list -mdrs config list -l +mdrs config ls ``` ### config delete @@ -62,6 +62,7 @@ Remove a registered remote host. ```shell mdrs config delete neurodata +mdrs config rm neurodata ``` ### login diff --git a/src/commands/config.rs b/src/commands/config.rs index bc723a3..6d56692 100644 --- a/src/commands/config.rs +++ b/src/commands/config.rs @@ -100,7 +100,7 @@ pub fn config_update(remote: &str, url: &str) -> Result<(), Box Result<(), Box> { +pub fn config_list() -> Result<(), Box> { let path = config_path(); if !path.exists() { return Ok(()); @@ -114,12 +114,8 @@ pub fn config_list(long: bool) -> Result<(), Box> { if sec == "default" { continue; } - if !long { - println!("{}:", sec); - } else { - let url = props.get("url").and_then(|v| v.clone()).unwrap_or_default(); - println!("{}:\t{}", sec, url); - } + let url = props.get("url").and_then(|v| v.clone()).unwrap_or_default(); + println!("{}:\t{}", sec, url); } Ok(()) } diff --git a/src/commands/config_subcommand.rs b/src/commands/config_subcommand.rs index 8252989..a4090e7 100644 --- a/src/commands/config_subcommand.rs +++ b/src/commands/config_subcommand.rs @@ -7,8 +7,10 @@ pub enum ConfigSubcommand { /// Update an existing remote host Update(ConfigUpdateArgs), /// List all remote hosts + #[command(alias = "ls")] List(ConfigListArgs), /// Delete a remote host + #[command(aliases = ["remove", "rm"])] Delete(ConfigDeleteArgs), } @@ -25,10 +27,7 @@ pub struct ConfigUpdateArgs { } #[derive(Args, Debug)] -pub struct ConfigListArgs { - #[arg(short, long)] - pub long: bool, -} +pub struct ConfigListArgs {} #[derive(Args, Debug)] pub struct ConfigDeleteArgs { diff --git a/src/main.rs b/src/main.rs index ee4d32e..daa0764 100644 --- a/src/main.rs +++ b/src/main.rs @@ -161,8 +161,8 @@ fn main() { handle_error(e); } } - ConfigSubcommand::List(args) => { - if let Err(e) = crate::commands::config::config_list(args.long) { + ConfigSubcommand::List(_) => { + if let Err(e) = crate::commands::config::config_list() { handle_error(e); } }