feat(daemon): select the active editor profile over the socket
This commit is contained in:
1 parent
343e03c27c
commit
502f2b0c51
9 files changed
+120
-2
No files matched your search
@@ -1578,6 +1578,13 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
|
||||
opts.force ? "true" : "false",
|
||||
opts.member_arg ? std::format(",\"member\":{}", Util::json_quote(*opts.member_arg))
|
||||
: std::string{});
|
||||
} else if (sub == "compdb_use") {
|
||||
if (opts.profile_arg.empty()) {
|
||||
std::cerr << "vbs daemon compdb use: --profile must not be empty\n";
|
||||
return 2;
|
||||
}
|
||||
request_json = std::format(R"({{"op":"compdb_use","profile":{}}})",
|
||||
Util::json_quote(opts.profile_arg));
|
||||
} else if (sub == "compdb_export") {
|
||||
if (opts.profile_arg.empty()) {
|
||||
std::cerr << "vbs daemon compdb export: --profile must not be empty\n";
|
||||
@@ -1622,6 +1629,7 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
|
||||
const auto request_timeout =
|
||||
sub == "build" ? std::chrono::milliseconds{std::chrono::hours{1}}
|
||||
: (sub == "watch_poll" || sub == "editor_status") ? std::chrono::milliseconds{5000}
|
||||
: sub == "compdb_use" ? std::chrono::milliseconds{10000}
|
||||
: sub == "watch_wait" ? std::chrono::milliseconds{10000}
|
||||
: sub == "describe" ? std::chrono::milliseconds{15000}
|
||||
: (sub == "ide_query" || sub == "ide_generate" || sub == "compdb_export")
|
||||
@@ -2607,6 +2615,11 @@ int main(int argc, char **argv) {
|
||||
daemon_opts.jobs_arg, "0");
|
||||
auto &daemon_compdb_cmd =
|
||||
daemon_cmd.subcommand("compdb", "Editor compilation database served by the daemon");
|
||||
auto &daemon_compdb_use_cmd =
|
||||
daemon_compdb_cmd.subcommand("use", "Select an already-published editor profile");
|
||||
configure_daemon_common(daemon_compdb_use_cmd);
|
||||
daemon_compdb_use_cmd.option_default("--profile", "-p", "Profile to select",
|
||||
daemon_opts.profile_arg, "debug");
|
||||
auto &daemon_compdb_export_cmd =
|
||||
daemon_compdb_cmd.subcommand("export", "Publish the profile compilation database");
|
||||
configure_daemon_common(daemon_compdb_export_cmd);
|
||||
@@ -2761,6 +2774,9 @@ int main(int argc, char **argv) {
|
||||
} else if (daemon_sub == "compdb" && parsed.matched_command_path.size() > 2 &&
|
||||
parsed.matched_command_path[2] == "export") {
|
||||
daemon_sub = "compdb_export";
|
||||
} else if (daemon_sub == "compdb" && parsed.matched_command_path.size() > 2 &&
|
||||
parsed.matched_command_path[2] == "use") {
|
||||
daemon_sub = "compdb_use";
|
||||
}
|
||||
return execute_daemon_command(daemon_sub, daemon_opts);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user