From bba72fb21aabb45770d22a21bc8f2261dc13c7fc Mon Sep 17 00:00:00 2001 From: Christoph Gysin Date: Sat, 23 Jan 2016 21:21:34 +0200 Subject: [PATCH 1/2] swaybar: debug option takes no argument --- swaybar/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swaybar/main.c b/swaybar/main.c index 98b75aee..66077592 100644 --- a/swaybar/main.c +++ b/swaybar/main.c @@ -1194,7 +1194,7 @@ int main(int argc, char **argv) { {"version", no_argument, NULL, 'v'}, {"socket", required_argument, NULL, 's'}, {"bar_id", required_argument, NULL, 'b'}, - {"debug", required_argument, NULL, 'd'}, + {"debug", no_argument, NULL, 'd'}, {0, 0, 0, 0} }; From ac3f36c09106cd10bcd98a525b94bd4b6f4675cd Mon Sep 17 00:00:00 2001 From: Christoph Gysin Date: Sat, 23 Jan 2016 21:22:27 +0200 Subject: [PATCH 2/2] swaybar: add --help option --- swaybar/main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/swaybar/main.c b/swaybar/main.c index 66077592..a3a3b56a 100644 --- a/swaybar/main.c +++ b/swaybar/main.c @@ -1191,6 +1191,7 @@ int main(int argc, char **argv) { bool debug = false; static struct option long_options[] = { + {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'v'}, {"socket", required_argument, NULL, 's'}, {"bar_id", required_argument, NULL, 'b'}, @@ -1198,10 +1199,23 @@ int main(int argc, char **argv) { {0, 0, 0, 0} }; + const char *usage = + "Usage: swaybar [options...] \n" + "\n" + " -h, --help Show help message and quit.\n" + " -v, --version Show the version number and quit.\n" + " -s, --socket Connect to sway via socket.\n" + " -b, --bar_id Bar ID for which to get the configuration.\n" + " -d, --debug Enable debugging.\n" + "\n" + " PLEASE NOTE that swaybar will be automatically started by sway as\n" + " soon as there is a 'bar' configuration block in your config file.\n" + " You should never need to start it manually.\n"; + int c; while (1) { int option_index = 0; - c = getopt_long(argc, argv, "vs:b:d", long_options, &option_index); + c = getopt_long(argc, argv, "hvs:b:d", long_options, &option_index); if (c == -1) { break; } @@ -1224,6 +1238,7 @@ int main(int argc, char **argv) { debug = true; break; default: + fprintf(stderr, "%s", usage); exit(EXIT_FAILURE); } }