swaybar: add --help option
This commit is contained in:
parent
bba72fb21a
commit
ac3f36c091
|
@ -1191,6 +1191,7 @@ int main(int argc, char **argv) {
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"version", no_argument, NULL, 'v'},
|
{"version", no_argument, NULL, 'v'},
|
||||||
{"socket", required_argument, NULL, 's'},
|
{"socket", required_argument, NULL, 's'},
|
||||||
{"bar_id", required_argument, NULL, 'b'},
|
{"bar_id", required_argument, NULL, 'b'},
|
||||||
|
@ -1198,10 +1199,23 @@ int main(int argc, char **argv) {
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char *usage =
|
||||||
|
"Usage: swaybar [options...] <output>\n"
|
||||||
|
"\n"
|
||||||
|
" -h, --help Show help message and quit.\n"
|
||||||
|
" -v, --version Show the version number and quit.\n"
|
||||||
|
" -s, --socket <socket> Connect to sway via socket.\n"
|
||||||
|
" -b, --bar_id <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;
|
int c;
|
||||||
while (1) {
|
while (1) {
|
||||||
int option_index = 0;
|
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) {
|
if (c == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1224,6 +1238,7 @@ int main(int argc, char **argv) {
|
||||||
debug = true;
|
debug = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
fprintf(stderr, "%s", usage);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue