Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options args enhancement #3722

Merged
merged 3 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion micromamba/src/activate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ set_activate_command(CLI::App* subcom)
static std::string name = "";
static bool stack = false;

subcom->add_option("prefix", name, "The prefix to activate");
subcom->add_option("prefix", name, "The prefix to activate")->option_text("PREFIX");
subcom->add_flag(
"--stack",
stack,
Expand Down
56 changes: 35 additions & 21 deletions micromamba/src/common_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ init_rc_options(CLI::App* subcom, Configuration& config)
rc_files.get_cli_config<std::vector<fs::u8path>>(),
rc_files.description()
)
->option_text("FILE1 FILE2...")
->group(cli_group);

auto& no_rc = config.at("no_rc");
Expand Down Expand Up @@ -108,10 +109,12 @@ init_prefix_options(CLI::App* subcom, Configuration& config)

auto& root = config.at("root_prefix");
subcom->add_option("-r,--root-prefix", root.get_cli_config<fs::u8path>(), root.description())
->option_text("PATH")
->group(cli_group);

auto& prefix = config.at("target_prefix");
subcom->add_option("-p,--prefix", prefix.get_cli_config<fs::u8path>(), prefix.description())
->option_text("PATH")
->group(cli_group);

auto& relocate_prefix = config.at("relocate_prefix");
Expand All @@ -121,10 +124,12 @@ init_prefix_options(CLI::App* subcom, Configuration& config)
relocate_prefix.get_cli_config<fs::u8path>(),
relocate_prefix.description()
)
->option_text("PATH")
->group(cli_group);

auto& name = config.at("env_name");
subcom->add_option("-n,--name", name.get_cli_config<std::string>(), name.description())
->option_text("NAME")
->group(cli_group);
}

Expand All @@ -136,6 +141,7 @@ init_network_options(CLI::App* subcom, Configuration& config)
auto& ssl_verify = config.at("ssl_verify");
subcom
->add_option("--ssl-verify", ssl_verify.get_cli_config<std::string>(), ssl_verify.description())
->option_text("'<false>' or PATH")
->group(cli_group);

auto& ssl_no_revoke = config.at("ssl_no_revoke");
Expand All @@ -150,6 +156,7 @@ init_network_options(CLI::App* subcom, Configuration& config)
cacert_path.get_cli_config<std::string>(),
cacert_path.description()
)
->option_text("PATH")
->group(cli_group);

auto& local_repodata_ttl = config.at("local_repodata_ttl");
Expand Down Expand Up @@ -180,6 +187,7 @@ init_channel_parser(CLI::App* subcom, Configuration& config)
channels.needs({ "override_channels" });
subcom
->add_option("-c,--channel", channels.get_cli_config<string_list>(), channels.description())
->option_text("CHANNEL")
->type_size(1)
->allow_extra_args(false);

Expand Down Expand Up @@ -212,11 +220,13 @@ init_channel_parser(CLI::App* subcom, Configuration& config)
->transform(CLI::CheckedTransformer(cp_map, CLI::ignore_case));

auto& channel_alias = config.at("channel_alias");
subcom->add_option(
"--channel-alias",
channel_alias.get_cli_config<std::string>(),
channel_alias.description()
);
subcom
->add_option(
"--channel-alias",
channel_alias.get_cli_config<std::string>(),
channel_alias.description()
)
->option_text("URL");

auto& strict_channel_priority = config.insert(
Configurable("strict_channel_priority", false)
Expand Down Expand Up @@ -342,15 +352,14 @@ init_install_options(CLI::App* subcom, Configuration& config)
init_channel_parser(subcom, config);

auto& specs = config.at("specs");
subcom->add_option(
"specs",
specs.get_cli_config<string_list>(),
"Specs to install into the environment"
);
subcom
->add_option("specs", specs.get_cli_config<string_list>(), "Specs to install into the environment")
->option_text("SPECS");

auto& file_specs = config.at("file_specs");
subcom
->add_option("-f,--file", file_specs.get_cli_config<string_list>(), file_specs.description())
->option_text("FILE")
->type_size(1)
->allow_extra_args(false);

Expand Down Expand Up @@ -437,11 +446,13 @@ init_install_options(CLI::App* subcom, Configuration& config)
auto& trusted_channels = config.at("trusted_channels");
// Allowing unlimited number of args (may be modified later if needed using `type_size` and
// `allow_extra_args`)
subcom->add_option(
"--trusted-channels",
trusted_channels.get_cli_config<string_list>(),
trusted_channels.description()
);
subcom
->add_option(
"--trusted-channels",
trusted_channels.get_cli_config<string_list>(),
trusted_channels.description()
)
->option_text("CHANNEL1 CHANNEL2...");

auto& repo_parsing = config.at("experimental_repodata_parsing");
subcom->add_flag(
Expand All @@ -451,17 +462,20 @@ init_install_options(CLI::App* subcom, Configuration& config)
);

auto& platform = config.at("platform");
subcom->add_option("--platform", platform.get_cli_config<std::string>(), platform.description());
subcom->add_option("--platform", platform.get_cli_config<std::string>(), platform.description())
->option_text("PLATFORM");

auto& no_deps = config.at("no_deps");
subcom->add_flag("--no-deps", no_deps.get_cli_config<bool>(), no_deps.description());
auto& only_deps = config.at("only_deps");
subcom->add_flag("--only-deps", only_deps.get_cli_config<bool>(), only_deps.description());

auto& categories = config.at("categories");
subcom->add_option(
"--category",
categories.get_cli_config<string_list>(),
"Categories of package to install from environment lockfile"
);
subcom
->add_option(
"--category",
categories.get_cli_config<string_list>(),
"Categories of package to install from environment lockfile"
)
->option_text("CAT1 CAT2...");
}
24 changes: 15 additions & 9 deletions micromamba/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ void
init_config_describe_options(CLI::App* subcom, mamba::Configuration& config)
{
auto& specs = config.at("specs");
subcom->add_option("configs", specs.get_cli_config<std::vector<std::string>>(), "Configuration keys");
subcom
->add_option("configs", specs.get_cli_config<std::vector<std::string>>(), "Configuration keys")
->option_text("CONFIG1 CONFIG2...");

auto& show_long_descriptions = config.at("show_config_long_descriptions");
subcom->add_flag(
Expand Down Expand Up @@ -352,7 +354,9 @@ set_config_remove_key_command(CLI::App* subcom, mamba::Configuration& config)
auto& remove_key = config.insert(Configurable("remove_key", std::string(""))
.group("Output, Prompt and Flow Control")
.description("Remove a configuration key and its values"));
subcom->add_option("remove_key", remove_key.get_cli_config<std::string>(), remove_key.description());
subcom
->add_option("remove_key", remove_key.get_cli_config<std::string>(), remove_key.description())
->option_text("KEY");

subcom->callback(
[&]()
Expand Down Expand Up @@ -413,11 +417,9 @@ set_config_remove_command(CLI::App* subcom, mamba::Configuration& config)
"Remove a configuration value from a list key. This removes all instances of the value."
)
);
subcom->add_option(
"remove",
remove_vec_map.get_cli_config<string_list>(),
remove_vec_map.description()
);
subcom
->add_option("remove", remove_vec_map.get_cli_config<string_list>(), remove_vec_map.description())
->option_text("VALUE");

subcom->callback(
[&]
Expand Down Expand Up @@ -495,7 +497,9 @@ set_config_set_command(CLI::App* subcom, mamba::Configuration& config)
auto& set_value = config.insert(Configurable("set_value", std::vector<std::string>({}))
.group("Output, Prompt and Flow Control")
.description("Set configuration value on rc file"));
subcom->add_option("set_value", set_value.get_cli_config<string_list>(), set_value.description());
subcom
->add_option("set_value", set_value.get_cli_config<string_list>(), set_value.description())
->option_text("VALUE");


subcom->callback(
Expand Down Expand Up @@ -543,7 +547,9 @@ set_config_get_command(CLI::App* subcom, mamba::Configuration& config)
auto& get_value = config.insert(Configurable("get_value", std::string(""))
.group("Output, Prompt and Flow Control")
.description("Display configuration value from rc file"));
subcom->add_option("get_value", get_value.get_cli_config<std::string>(), get_value.description());
subcom
->add_option("get_value", get_value.get_cli_config<std::string>(), get_value.description())
->option_text("VALUE");

subcom->callback(
[&]
Expand Down
3 changes: 2 additions & 1 deletion micromamba/src/constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ init_constructor_parser(CLI::App* subcom, Configuration& config)
.group("cli")
.description("Extract the conda pkgs in <prefix>/pkgs"));

subcom->add_option("-p,--prefix", prefix.get_cli_config<fs::u8path>(), prefix.description());
subcom->add_option("-p,--prefix", prefix.get_cli_config<fs::u8path>(), prefix.description())
->option_text("PATH");

auto& extract_conda_pkgs = config.insert(Configurable("constructor_extract_conda_pkgs", false)
.group("cli")
Expand Down
12 changes: 7 additions & 5 deletions micromamba/src/env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,13 @@ set_env_command(CLI::App* com, Configuration& config)
init_prefix_options(update_subcom, config);

auto& file_specs = config.at("file_specs");
update_subcom->add_option(
"-f,--file",
file_specs.get_cli_config<std::vector<std::string>>(),
file_specs.description()
);
update_subcom
->add_option(
"-f,--file",
file_specs.get_cli_config<std::vector<std::string>>(),
file_specs.description()
)
->option_text("FILE");

static bool remove_not_specified = false;
update_subcom->add_flag(
Expand Down
3 changes: 2 additions & 1 deletion micromamba/src/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ init_list_parser(CLI::App* subcom, Configuration& config)
auto& regex = config.insert(Configurable("list_regex", std::string(""))
.group("cli")
.description("List only packages matching a regular expression"));
subcom->add_option("regex", regex.get_cli_config<std::string>(), regex.description());
subcom->add_option("regex", regex.get_cli_config<std::string>(), regex.description())
->option_text("REGEX");

auto& full_name = config.insert(Configurable("full_name", false)
.group("cli")
Expand Down
24 changes: 13 additions & 11 deletions micromamba/src/login.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void
set_logout_command(CLI::App* subcom)
{
static std::string host;
subcom->add_option("host", host, "Host for the account");
subcom->add_option("host", host, "Host for the account")->option_text("HOST");

static bool all;
subcom->add_flag("--all", all, "Log out from all hosts");
Expand Down Expand Up @@ -118,19 +118,21 @@ set_login_command(CLI::App* subcom)
static bool pass_stdin = false;
static bool token_stdin = false;
static bool bearer_stdin = false;
subcom->add_option("-p,--password", pass, "Password for account");
subcom->add_option("-u,--username", user, "User name for the account");
subcom->add_option("-t,--token", token, "Token for the account");
subcom->add_option("-b,--bearer", bearer, "Bearer token for the account");
subcom->add_option("-p,--password", pass, "Password for account")->option_text("PASSWORD");
subcom->add_option("-u,--username", user, "User name for the account")->option_text("USERNAME");
subcom->add_option("-t,--token", token, "Token for the account")->option_text("TOKEN");
subcom->add_option("-b,--bearer", bearer, "Bearer token for the account")->option_text("BEARER");
subcom->add_flag("--password-stdin", pass_stdin, "Read password from stdin");
subcom->add_flag("--token-stdin", token_stdin, "Read token from stdin");
subcom->add_flag("--bearer-stdin", bearer_stdin, "Read bearer token from stdin");
subcom->add_option(
"host",
host,
"Host for the account. The scheme (e.g. https://) is ignored\n"
"but not the port (optional) nor the channel (optional)."
);
subcom
->add_option(
"host",
host,
"Host for the account. The scheme (e.g. https://) is ignored\n"
"but not the port (optional) nor the channel (optional)."
)
->option_text("HOST");

subcom->callback(
[]()
Expand Down
59 changes: 34 additions & 25 deletions micromamba/src/package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ set_package_command(CLI::App* subcom, Configuration& config)

auto extract_subcom = subcom->add_subcommand("extract");
init_general_options(extract_subcom, config);
extract_subcom->add_option("archive", infile, "Archive to extract");
extract_subcom->add_option("dest", dest, "Destination folder");
extract_subcom->add_option("archive", infile, "Archive to extract")->option_text("ARCHIVE");
extract_subcom->add_option("dest", dest, "Destination folder")->option_text("FOLDER");
extract_subcom->callback(
[&]
{
Expand All @@ -43,18 +43,23 @@ set_package_command(CLI::App* subcom, Configuration& config)

auto compress_subcom = subcom->add_subcommand("compress");
init_general_options(compress_subcom, config);
compress_subcom->add_option("folder", infile, "Folder to compress");
compress_subcom->add_option("dest", dest, "Destination (e.g. myfile-3.1-0.tar.bz2 or .conda)");
compress_subcom->add_option(
"-c,--compression-level",
compression_level,
"Compression level from 0-9 (tar.bz2, default is 9), and 1-22 (conda, default is 15)"
);
compress_subcom->add_option(
"--compression-threads",
compression_threads,
"Compression threads (only relevant for .conda packages, default is 1)"
);
compress_subcom->add_option("folder", infile, "Folder to compress")->option_text("FOLDER");
compress_subcom->add_option("dest", dest, "Destination (e.g. myfile-3.1-0.tar.bz2 or .conda)")
->option_text("DEST");
compress_subcom
->add_option(
"-c,--compression-level",
compression_level,
"Compression level from 0-9 (tar.bz2, default is 9), and 1-22 (conda, default is 15)"
)
->option_text("COMP_LEVEL");
compress_subcom
->add_option(
"--compression-threads",
compression_threads,
"Compression threads (only relevant for .conda packages, default is 1)"
)
->option_text("COMP_THREADS");
compress_subcom->callback(
[&]()
{
Expand Down Expand Up @@ -84,17 +89,21 @@ set_package_command(CLI::App* subcom, Configuration& config)

auto transmute_subcom = subcom->add_subcommand("transmute");
init_general_options(transmute_subcom, config);
transmute_subcom->add_option("infile", infile, "Folder to compress");
transmute_subcom->add_option(
"-c,--compression-level",
compression_level,
"Compression level from 0-9 (tar.bz2, default is 9), and 1-22 (conda, default is 15)"
);
transmute_subcom->add_option(
"--compression-threads",
compression_threads,
"Compression threads (only relevant for .conda packages, default is 1)"
);
transmute_subcom->add_option("infile", infile, "Folder to compress")->option_text("FOLDER");
transmute_subcom
->add_option(
"-c,--compression-level",
compression_level,
"Compression level from 0-9 (tar.bz2, default is 9), and 1-22 (conda, default is 15)"
)
->option_text("COMP_LEVEL");
transmute_subcom
->add_option(
"--compression-threads",
compression_threads,
"Compression threads (only relevant for .conda packages, default is 1)"
)
->option_text("COMP_THREADS");
transmute_subcom->callback(
[&]()
{
Expand Down
8 changes: 3 additions & 5 deletions micromamba/src/remove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ set_remove_command(CLI::App* subcom, Configuration& config)
init_prefix_options(subcom, config);

auto& specs = config.at("specs");
subcom->add_option(
"specs",
specs.get_cli_config<string_list>(),
"Specs to remove from the environment"
);
subcom
->add_option("specs", specs.get_cli_config<string_list>(), "Specs to remove from the environment")
->option_text("SPECS");

static bool remove_all = false, force = false, prune_deps = true;
subcom->add_flag("-a,--all", remove_all, "Remove all packages in the environment");
Expand Down
Loading
Loading