Skip to content

Commit 9417d6f

Browse files
committed
core/command: deprecate qs msg
1 parent 4205293 commit 9417d6f

File tree

3 files changed

+49
-28
lines changed

3 files changed

+49
-28
lines changed

src/launch/command.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -285,26 +285,21 @@ int killInstances(CommandState& cmd) {
285285
});
286286
}
287287

288-
int msgInstance(CommandState& cmd) {
288+
int ipcCommand(CommandState& cmd) {
289289
InstanceLockInfo instance;
290290
auto r = selectInstance(cmd, &instance);
291291
if (r != 0) return r;
292292

293293
return IpcClient::connect(instance.instance.instanceId, [&](IpcClient& client) {
294-
if (cmd.ipc.info) {
295-
return qs::io::ipc::comm::queryMetadata(&client, *cmd.ipc.target, *cmd.ipc.function);
294+
if (*cmd.ipc.show || cmd.ipc.showOld) {
295+
return qs::io::ipc::comm::queryMetadata(&client, *cmd.ipc.target, *cmd.ipc.name);
296296
} else {
297297
QVector<QString> arguments;
298298
for (auto& arg: cmd.ipc.arguments) {
299299
arguments += *arg;
300300
}
301301

302-
return qs::io::ipc::comm::callFunction(
303-
&client,
304-
*cmd.ipc.target,
305-
*cmd.ipc.function,
306-
arguments
307-
);
302+
return qs::io::ipc::comm::callFunction(&client, *cmd.ipc.target, *cmd.ipc.name, arguments);
308303
}
309304

310305
return -1;
@@ -423,8 +418,8 @@ int runCommand(int argc, char** argv, QCoreApplication* coreApplication) {
423418
return listInstances(state);
424419
} else if (*state.subcommand.kill) {
425420
return killInstances(state);
426-
} else if (*state.subcommand.msg) {
427-
return msgInstance(state);
421+
} else if (*state.subcommand.msg || *state.ipc.ipc) {
422+
return ipcCommand(state);
428423
} else {
429424
if (strcmp(qVersion(), QT_VERSION_STR) != 0) {
430425
qWarning() << "\033[31mQuickshell was built against Qt" << QT_VERSION_STR

src/launch/launch_p.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,12 @@ struct CommandState {
6868
} output;
6969

7070
struct {
71-
bool info = false;
71+
CLI::App* ipc = nullptr;
72+
CLI::App* show = nullptr;
73+
CLI::App* call = nullptr;
74+
bool showOld = false;
7275
QStringOption target;
73-
QStringOption function;
76+
QStringOption name;
7477
std::vector<QStringOption> arguments;
7578
} ipc;
7679

src/launch/parsecommand.cpp

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ int parseCommand(int argc, char** argv, CommandState& state) {
135135
->description("Rules to apply to the log being read, in the format of QT_LOGGING_RULES.");
136136

137137
auto* instance = addInstanceSelection(sub)->excludes(file);
138-
addConfigSelection(sub)->excludes(instance)->excludes(file);
138+
addConfigSelection(sub, true)->excludes(instance)->excludes(file);
139139
addLoggingOptions(sub, false);
140140

141141
state.subcommand.log = sub;
@@ -168,30 +168,53 @@ int parseCommand(int argc, char** argv, CommandState& state) {
168168
}
169169

170170
{
171-
auto* sub = cli->add_subcommand("msg", "Send messages to IpcHandlers.")->require_option();
171+
auto* sub = cli->add_subcommand("ipc", "Communicate with other Quickshell instances.")
172+
->require_subcommand();
173+
state.ipc.ipc = sub;
172174

173-
auto* target = sub->add_option("target", state.ipc.target, "The target to message.");
175+
auto* instance = addInstanceSelection(sub);
176+
addConfigSelection(sub, true)->excludes(instance);
177+
addLoggingOptions(sub, false, true);
178+
179+
{
180+
auto* show = sub->add_subcommand("show", "Print information about available IPC targets.");
181+
state.ipc.show = show;
182+
}
183+
184+
{
185+
auto* call = sub->add_subcommand("call", "Call an IpcHandler function.");
186+
state.ipc.call = call;
174187

175-
auto* function = sub->add_option("function", state.ipc.function)
176-
->description("The function to call in the target.")
177-
->needs(target);
188+
call->add_option("target", state.ipc.target, "The target to message.");
178189

179-
auto* arguments = sub->add_option("arguments", state.ipc.arguments)
180-
->description("Arguments to the called function.")
181-
->needs(function)
182-
->allow_extra_args();
190+
call->add_option("function", state.ipc.name)
191+
->description("The function to call in the target.");
183192

184-
sub->add_flag("-s,--show", state.ipc.info)
193+
call->add_option("arguments", state.ipc.arguments)
194+
->description("Arguments to the called function.")
195+
->allow_extra_args();
196+
}
197+
}
198+
199+
{
200+
auto* sub = cli->add_subcommand("msg", "[DEPRECATED] Moved to `ipc call`.")->require_option();
201+
202+
sub->add_option("target", state.ipc.target, "The target to message.");
203+
204+
sub->add_option("function", state.ipc.name)->description("The function to call in the target.");
205+
206+
sub->add_option("arguments", state.ipc.arguments)
207+
->description("Arguments to the called function.")
208+
->allow_extra_args();
209+
210+
sub->add_flag("-s,--show", state.ipc.showOld)
185211
->description("Print information about a function or target if given, or all available "
186-
"targets if not.")
187-
->excludes(arguments);
212+
"targets if not.");
188213

189214
auto* instance = addInstanceSelection(sub);
190215
addConfigSelection(sub, true)->excludes(instance);
191216
addLoggingOptions(sub, false, true);
192217

193-
sub->require_option();
194-
195218
state.subcommand.msg = sub;
196219
}
197220

0 commit comments

Comments
 (0)