Skip to content

Commit

Permalink
g3proxy-ctl: add subcommand alias
Browse files Browse the repository at this point in the history
  • Loading branch information
zh-jq-b committed Aug 18, 2023
1 parent 7ee04c6 commit 3c4a7e2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions g3proxy/utils/ctl/src/user_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ const COMMAND_ARG_FILE: &str = "file";

const SUBCOMMAND_LIST_STATIC_USER: &str = "list-static-user";
const SUBCOMMAND_LIST_DYNAMIC_USER: &str = "list-dynamic-user";
const SUBCOMMAND_PUBLISH_DYNAMIC_USER: &str = "publish-dynamic-user";
const SUBCOMMAND_PUBLISH_USER: &str = "publish-user";

pub fn command() -> Command {
Command::new(COMMAND)
.arg(Arg::new(COMMAND_ARG_NAME).required(true).num_args(1))
.subcommand(Command::new(SUBCOMMAND_LIST_STATIC_USER))
.subcommand(Command::new(SUBCOMMAND_LIST_DYNAMIC_USER))
.subcommand(Command::new(SUBCOMMAND_LIST_STATIC_USER).about("List static users"))
.subcommand(Command::new(SUBCOMMAND_LIST_DYNAMIC_USER).about("List dynamic users"))
.subcommand(
Command::new(SUBCOMMAND_PUBLISH_DYNAMIC_USER)
.long_flag("publish")
Command::new(SUBCOMMAND_PUBLISH_USER)
.about("Publish dynamic users")
.visible_aliases(["publish", "publish-dynamic-user"])
.arg(
Arg::new(COMMAND_ARG_FILE)
.required(true)
Expand All @@ -61,7 +62,7 @@ pub async fn run(client: &proc_control::Client, args: &ArgMatches) -> CommandRes
match subcommand {
SUBCOMMAND_LIST_STATIC_USER => list_static_user(&user_group).await,
SUBCOMMAND_LIST_DYNAMIC_USER => list_dynamic_user(&user_group).await,
SUBCOMMAND_PUBLISH_DYNAMIC_USER => publish_dynamic_user(&user_group, args).await,
SUBCOMMAND_PUBLISH_USER => publish_dynamic_user(&user_group, args).await,
cmd => Err(CommandError::Cli(format!("unsupported subcommand {cmd}"))),
}
} else {
Expand Down

0 comments on commit 3c4a7e2

Please sign in to comment.