diff options
author | 2016-01-23 14:35:27 -0500 | |
---|---|---|
committer | 2016-01-23 14:35:27 -0500 | |
commit | ed685718155d24562a752576f4c5340792cac4a5 (patch) | |
tree | 3b5239943a68a0b74194aba4baa642236e54dc9e /swaybar/main.c | |
parent | Merge pull request #464 from christophgysin/swaylock (diff) | |
parent | swaybar: add --help option (diff) | |
download | sway-ed685718155d24562a752576f4c5340792cac4a5.tar.gz sway-ed685718155d24562a752576f4c5340792cac4a5.tar.zst sway-ed685718155d24562a752576f4c5340792cac4a5.zip |
Merge pull request #466 from christophgysin/swaybar_usage
swaybar: add usage
Diffstat (limited to 'swaybar/main.c')
-rw-r--r-- | swaybar/main.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/swaybar/main.c b/swaybar/main.c index 98b75aee..a3a3b56a 100644 --- a/swaybar/main.c +++ b/swaybar/main.c | |||
@@ -1191,17 +1191,31 @@ int main(int argc, char **argv) { | |||
1191 | bool debug = false; | 1191 | bool debug = false; |
1192 | 1192 | ||
1193 | static struct option long_options[] = { | 1193 | static struct option long_options[] = { |
1194 | {"help", no_argument, NULL, 'h'}, | ||
1194 | {"version", no_argument, NULL, 'v'}, | 1195 | {"version", no_argument, NULL, 'v'}, |
1195 | {"socket", required_argument, NULL, 's'}, | 1196 | {"socket", required_argument, NULL, 's'}, |
1196 | {"bar_id", required_argument, NULL, 'b'}, | 1197 | {"bar_id", required_argument, NULL, 'b'}, |
1197 | {"debug", required_argument, NULL, 'd'}, | 1198 | {"debug", no_argument, NULL, 'd'}, |
1198 | {0, 0, 0, 0} | 1199 | {0, 0, 0, 0} |
1199 | }; | 1200 | }; |
1200 | 1201 | ||
1202 | const char *usage = | ||
1203 | "Usage: swaybar [options...] <output>\n" | ||
1204 | "\n" | ||
1205 | " -h, --help Show help message and quit.\n" | ||
1206 | " -v, --version Show the version number and quit.\n" | ||
1207 | " -s, --socket <socket> Connect to sway via socket.\n" | ||
1208 | " -b, --bar_id <id> Bar ID for which to get the configuration.\n" | ||
1209 | " -d, --debug Enable debugging.\n" | ||
1210 | "\n" | ||
1211 | " PLEASE NOTE that swaybar will be automatically started by sway as\n" | ||
1212 | " soon as there is a 'bar' configuration block in your config file.\n" | ||
1213 | " You should never need to start it manually.\n"; | ||
1214 | |||
1201 | int c; | 1215 | int c; |
1202 | while (1) { | 1216 | while (1) { |
1203 | int option_index = 0; | 1217 | int option_index = 0; |
1204 | c = getopt_long(argc, argv, "vs:b:d", long_options, &option_index); | 1218 | c = getopt_long(argc, argv, "hvs:b:d", long_options, &option_index); |
1205 | if (c == -1) { | 1219 | if (c == -1) { |
1206 | break; | 1220 | break; |
1207 | } | 1221 | } |
@@ -1224,6 +1238,7 @@ int main(int argc, char **argv) { | |||
1224 | debug = true; | 1238 | debug = true; |
1225 | break; | 1239 | break; |
1226 | default: | 1240 | default: |
1241 | fprintf(stderr, "%s", usage); | ||
1227 | exit(EXIT_FAILURE); | 1242 | exit(EXIT_FAILURE); |
1228 | } | 1243 | } |
1229 | } | 1244 | } |