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>
This commit is contained in:
2026-04-17 18:59:18 +09:00
parent 0d474e7913
commit 7947c3bae9
4 changed files with 10 additions and 14 deletions
+2 -1
View File
@@ -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
+3 -7
View File
@@ -100,7 +100,7 @@ pub fn config_update(remote: &str, url: &str) -> Result<(), Box<dyn std::error::
Ok(())
}
pub fn config_list(long: bool) -> Result<(), Box<dyn std::error::Error>> {
pub fn config_list() -> Result<(), Box<dyn std::error::Error>> {
let path = config_path();
if !path.exists() {
return Ok(());
@@ -114,12 +114,8 @@ pub fn config_list(long: bool) -> Result<(), Box<dyn std::error::Error>> {
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(())
}
+3 -4
View File
@@ -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 {
+2 -2
View File
@@ -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);
}
}