use clap::{Command, ValueHint, arg, value_parser};
use std::path::PathBuf;
use super::output_flag;
pub fn subcommand_config() -> Command {
let subcommand_config_set_hsm = Command::new("hsm")
.about("Set the active node group")
.arg(arg!(<HSM_GROUP_NAME> "Node group name").value_name("GROUP_NAME"));
let subcommand_config_set_parent_hsm = Command::new("parent-hsm")
.about("Set the parent node group")
.arg(arg!(<HSM_GROUP_NAME> "Node group name").value_name("GROUP_NAME"));
let subcommand_config_set_site = Command::new("site")
.about("Set the active site")
.arg(arg!(<SITE_NAME> "Site name"));
let subcommand_config_set_log = Command::new("log")
.about("Set the log verbosity level")
.arg(
arg!(<LOG_LEVEL> "Log verbosity level")
.value_parser(["error", "warn", "info", "debug", "trace"]),
);
let subcommand_config_unset_hsm =
Command::new("hsm").about("Clear the active node group");
let subcommand_config_unset_parent_hsm =
Command::new("parent-hsm").about("Clear the parent node group");
let subcommand_config_unset_auth =
Command::new("auth").about("Clear the cached authentication token");
Command::new("config")
.arg_required_else_help(true)
.about("Show or change CLI-side settings (active site, default node group, log level)")
.subcommand(
Command::new("show")
.about("Show current configuration values")
.arg(output_flag()),
)
.subcommand(
Command::new("set")
.arg_required_else_help(true)
.about("Set a configuration value")
.subcommand(subcommand_config_set_hsm)
.subcommand(subcommand_config_set_parent_hsm)
.subcommand(subcommand_config_set_site)
.subcommand(subcommand_config_set_log),
)
.subcommand(
Command::new("unset")
.arg_required_else_help(true)
.about("Clear a configuration value")
.subcommand(subcommand_config_unset_hsm)
.subcommand(subcommand_config_unset_parent_hsm)
.subcommand(subcommand_config_unset_auth),
)
.subcommand(
Command::new("gen-autocomplete")
.about("Generate shell completion scripts")
.arg(
arg!(-s --shell <SHELL> "Shell type (guessed from $SHELL if omitted)")
.value_parser(["bash", "zsh", "fish"]),
)
.arg(
arg!(-p --path <PATH> "Directory to write the script (prints to stdout if omitted)")
.value_parser(value_parser!(PathBuf))
.value_hint(ValueHint::DirPath),
),
)
}