Unverified Commit c1b623a1 authored by Erik Reider's avatar Erik Reider Committed by GitHub

Fix client printing help when running with --skip-wait (#605)

parent 18bc4570
...@@ -133,9 +133,7 @@ private void print_subscribe_waybar () { ...@@ -133,9 +133,7 @@ private void print_subscribe_waybar () {
} }
} }
public int command_line (ref string[] args) { public int command_line (ref string[] args, bool skip_wait) {
bool skip_wait = "--skip-wait" in args || "-sw" in args;
// Used to know how many args the current command consumed // Used to know how many args the current command consumed
int used_args = 1; int used_args = 1;
try { try {
...@@ -313,6 +311,7 @@ public int command_line (ref string[] args) { ...@@ -313,6 +311,7 @@ public int command_line (ref string[] args) {
stderr.printf ("Could not find monitor: \"%s\"!", args[1]); stderr.printf ("Could not find monitor: \"%s\"!", args[1]);
break; break;
default: default:
print ("Unknown command: \"%s\"\n", args[0]);
print_help (args); print_help (args);
break; break;
} }
...@@ -337,18 +336,28 @@ int try_connect (owned string[] args) { ...@@ -337,18 +336,28 @@ int try_connect (owned string[] args) {
BusType.SESSION, BusType.SESSION,
"org.erikreider.swaync.cc", "org.erikreider.swaync.cc",
"/org/erikreider/swaync/cc"); "/org/erikreider/swaync/cc");
bool skip_wait = "--skip-wait" in args || "-sw" in args;
bool one_arg = true; bool one_arg = true;
while (args.length > 0) { while (args.length > 0) {
if (args[0] == "--skip-wait" || args[0] == "-sw") {
args = args[1:];
continue;
}
if (!one_arg) { if (!one_arg) {
// Separate each command output // Separate each command output
print ("\n"); print ("\n");
} }
if (command_line (ref args) == 1) { if (command_line (ref args, skip_wait) == 1) {
print_connection_error (); print_connection_error ();
return 1; return 1;
} }
one_arg = false; one_arg = false;
} }
// Should only be reached if the args only contains --skip-wait or -sw
if (one_arg) {
stderr.printf ("Skipping wait, but with no action.");
}
return 0; return 0;
} catch (Error e) { } catch (Error e) {
print_connection_error (); print_connection_error ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment