feat: filter daemon actions by kind; show registry release detail
This commit is contained in:
1 parent
624016d904
commit
691560a369
11 files changed
+228
-21
No files matched your search
+57
-14
@@ -1157,6 +1157,7 @@ int execute_publish_binary_command(const PublishBinaryCmdOptions &opts) {
|
||||
struct ReleasesCmdOptions {
|
||||
std::optional<std::string> registry_arg;
|
||||
std::optional<std::string> name_arg;
|
||||
std::optional<std::string> version_arg;
|
||||
std::string token_env{"VBS_REGISTRY_TOKEN"};
|
||||
};
|
||||
|
||||
@@ -1182,6 +1183,29 @@ int execute_releases_list_command(const ReleasesCmdOptions &opts) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int execute_releases_show_command(const ReleasesCmdOptions &opts) {
|
||||
const std::string registry_url = opts.registry_arg
|
||||
? *opts.registry_arg
|
||||
: Void::Configuration::get_env_or("VBS_REGISTRY_URL", "");
|
||||
if (registry_url.empty() || !opts.name_arg || !opts.version_arg) {
|
||||
std::cerr << "vbs releases show: --registry, --name, and --version are required\n";
|
||||
return 2;
|
||||
}
|
||||
Package::RegistryAuth auth{Void::Configuration::get_env_or(opts.token_env, "")};
|
||||
auto release =
|
||||
Package::fetch_release_detail(registry_url, *opts.name_arg, *opts.version_arg, auth);
|
||||
if (!release) {
|
||||
std::cerr << "vbs releases show: " << release.error().message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
std::cout << "name=" << release->name << " version=" << release->version
|
||||
<< " sha256=" << release->sha256 << " size=" << release->size_bytes
|
||||
<< " yanked=" << (release->yanked ? "true" : "false")
|
||||
<< " binaries=" << release->binary_count
|
||||
<< " signed=" << (release->signature && release->public_key ? "yes" : "no") << '\n';
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct BinariesCmdOptions {
|
||||
std::optional<std::string> registry_arg;
|
||||
std::optional<std::string> name_arg;
|
||||
@@ -1534,6 +1558,7 @@ struct DaemonCmdOptions {
|
||||
std::optional<std::string> member_arg;
|
||||
std::string graph_format_arg{"dot"};
|
||||
std::optional<std::string> target_arg;
|
||||
std::optional<std::string> action_kind_arg;
|
||||
std::optional<std::string> pack_output_arg;
|
||||
std::optional<std::string> prefix_arg;
|
||||
std::optional<std::string> input_arg;
|
||||
@@ -1634,19 +1659,23 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
|
||||
Util::json_quote(opts.profile_arg),
|
||||
Util::json_quote(opts.graph_format_arg));
|
||||
} else if (sub == "actions") {
|
||||
request_json = std::format(R"({{"op":"actions","profile":{},"limit":{}}})",
|
||||
Util::json_quote(opts.profile_arg), opts.limit_arg);
|
||||
request_json = std::format(
|
||||
R"({{"op":"actions","profile":{},"limit":{}{}}})", Util::json_quote(opts.profile_arg),
|
||||
opts.limit_arg,
|
||||
opts.action_kind_arg
|
||||
? std::format(",\"kind\":{}", Util::json_quote(*opts.action_kind_arg))
|
||||
: std::string{});
|
||||
} else if (sub == "target_flags") {
|
||||
if (!opts.target_arg || opts.target_arg->empty()) {
|
||||
std::cerr << "vbs daemon target flags: --name must not be empty\n";
|
||||
return 2;
|
||||
}
|
||||
request_json = std::format(
|
||||
R"({{"op":"target_flags","profile":{},"target":{}{}}})",
|
||||
Util::json_quote(opts.profile_arg), Util::json_quote(*opts.target_arg),
|
||||
opts.file_filter_arg
|
||||
? std::format(",\"file\":{}", Util::json_quote(*opts.file_filter_arg))
|
||||
: std::string{});
|
||||
request_json =
|
||||
std::format(R"({{"op":"target_flags","profile":{},"target":{}{}}})",
|
||||
Util::json_quote(opts.profile_arg), Util::json_quote(*opts.target_arg),
|
||||
opts.file_filter_arg
|
||||
? std::format(",\"file\":{}", Util::json_quote(*opts.file_filter_arg))
|
||||
: std::string{});
|
||||
} else if (sub == "target_info") {
|
||||
if (!opts.target_arg || opts.target_arg->empty()) {
|
||||
std::cerr << "vbs daemon target: --name must not be empty\n";
|
||||
@@ -2527,6 +2556,16 @@ int main(int argc, char **argv) {
|
||||
releases_opts.token_env, "VBS_REGISTRY_TOKEN");
|
||||
add_log_flags(releases_list_cmd);
|
||||
|
||||
auto &releases_show_cmd = releases_cmd.subcommand("show", "Show one release's details");
|
||||
releases_show_cmd
|
||||
.option("--registry", "-r", "Registry base URL (or VBS_REGISTRY_URL)",
|
||||
releases_opts.registry_arg)
|
||||
.option("--name", "-n", "Package name", releases_opts.name_arg)
|
||||
.option("--version", "-v", "Release version", releases_opts.version_arg)
|
||||
.option_default("--token-env", "", "Environment variable holding bearer token",
|
||||
releases_opts.token_env, "VBS_REGISTRY_TOKEN");
|
||||
add_log_flags(releases_show_cmd, false); // `-v` is `--version` on releases show.
|
||||
|
||||
auto &binaries_cmd =
|
||||
root.subcommand("binaries", "Inspect prebuilt binary variants in a package registry");
|
||||
auto configure_binaries = [&](Void::Argparse::Parser &p) {
|
||||
@@ -2672,9 +2711,9 @@ int main(int argc, char **argv) {
|
||||
daemon_cmd.subcommand("describe", "Describe a project's build graph via the daemon");
|
||||
configure_daemon_common(daemon_describe_cmd);
|
||||
daemon_describe_cmd
|
||||
.option_default("--profile", "-p", "Profile to evaluate", daemon_opts.profile_arg,
|
||||
"debug")
|
||||
.option("--member", "", "Workspace member to describe (default: all)", daemon_opts.member_arg);
|
||||
.option_default("--profile", "-p", "Profile to evaluate", daemon_opts.profile_arg, "debug")
|
||||
.option("--member", "", "Workspace member to describe (default: all)",
|
||||
daemon_opts.member_arg);
|
||||
auto &daemon_build_cmd = daemon_cmd.subcommand("build", "Build a project graph via the daemon");
|
||||
configure_daemon_common(daemon_build_cmd);
|
||||
daemon_build_cmd
|
||||
@@ -2779,8 +2818,7 @@ int main(int argc, char **argv) {
|
||||
"flags", "Report one target's bounded compile arguments per unit");
|
||||
configure_daemon_common(daemon_target_flags_cmd);
|
||||
daemon_target_flags_cmd
|
||||
.option_default("--profile", "-p", "Profile to evaluate", daemon_opts.profile_arg,
|
||||
"debug")
|
||||
.option_default("--profile", "-p", "Profile to evaluate", daemon_opts.profile_arg, "debug")
|
||||
.option("--name", "-n", "Target name", daemon_opts.target_arg)
|
||||
.option("--file", "", "Only units whose source path ends with this value",
|
||||
daemon_opts.file_filter_arg);
|
||||
@@ -2793,7 +2831,9 @@ int main(int argc, char **argv) {
|
||||
daemon_cmd.subcommand("actions", "List lowered build actions via the daemon");
|
||||
configure_daemon_common(daemon_actions_cmd);
|
||||
daemon_actions_cmd
|
||||
.option_default("--profile", "-p", "Profile to evaluate", daemon_opts.profile_arg, "debug")
|
||||
.option_default("--profile", "-p", "Profile to evaluate", daemon_opts.profile_arg,
|
||||
"debug")
|
||||
.option("--kind", "", "Only actions of this kind (compile|link|archive|...)", daemon_opts.action_kind_arg)
|
||||
.option_default("--limit", "", "Maximum actions returned (0-1000)", daemon_opts.limit_arg,
|
||||
"100");
|
||||
auto &daemon_graph_cmd =
|
||||
@@ -2912,6 +2952,9 @@ int main(int argc, char **argv) {
|
||||
return execute_binaries_command(parsed.matched_command_path.at(1), binaries_opts);
|
||||
}
|
||||
if (cmd == "releases") {
|
||||
if (parsed.matched_command_path.at(1) == "show") {
|
||||
return execute_releases_show_command(releases_opts);
|
||||
}
|
||||
return execute_releases_list_command(releases_opts);
|
||||
}
|
||||
if (cmd == "bridge") {
|
||||
|
||||
Reference in new issue
Block a user