diff options
-rw-r--r-- | sway.1.txt | 3 | ||||
-rw-r--r-- | sway/main.c | 8 |
2 files changed, 10 insertions, 1 deletions
@@ -17,6 +17,9 @@ Synopsis | |||
17 | Options | 17 | Options |
18 | ------- | 18 | ------- |
19 | 19 | ||
20 | *-h, --help*:: | ||
21 | Show help message and quit. | ||
22 | |||
20 | *-c, \--config* <config>:: | 23 | *-c, \--config* <config>:: |
21 | Specifies a config file. | 24 | Specifies a config file. |
22 | 25 | ||
diff --git a/sway/main.c b/sway/main.c index 7b24d405..473a0990 100644 --- a/sway/main.c +++ b/sway/main.c | |||
@@ -55,6 +55,7 @@ int main(int argc, char **argv) { | |||
55 | static int verbose = 0, debug = 0, validate = 0; | 55 | static int verbose = 0, debug = 0, validate = 0; |
56 | 56 | ||
57 | static struct option long_options[] = { | 57 | static struct option long_options[] = { |
58 | {"help", no_argument, NULL, 'h'}, | ||
58 | {"config", required_argument, NULL, 'c'}, | 59 | {"config", required_argument, NULL, 'c'}, |
59 | {"validate", no_argument, &validate, 1}, | 60 | {"validate", no_argument, &validate, 1}, |
60 | {"debug", no_argument, &debug, 1}, | 61 | {"debug", no_argument, &debug, 1}, |
@@ -69,6 +70,7 @@ int main(int argc, char **argv) { | |||
69 | const char* usage = | 70 | const char* usage = |
70 | "Usage: sway [options] [command]\n" | 71 | "Usage: sway [options] [command]\n" |
71 | "\n" | 72 | "\n" |
73 | " -h, --help Show help message and quit.\n" | ||
72 | " -c, --config <config> Specify a config file.\n" | 74 | " -c, --config <config> Specify a config file.\n" |
73 | " -C, --validate Check the validity of the config file, then exit.\n" | 75 | " -C, --validate Check the validity of the config file, then exit.\n" |
74 | " -d, --debug Enables full logging, including debug information.\n" | 76 | " -d, --debug Enables full logging, including debug information.\n" |
@@ -80,13 +82,17 @@ int main(int argc, char **argv) { | |||
80 | int c; | 82 | int c; |
81 | while (1) { | 83 | while (1) { |
82 | int option_index = 0; | 84 | int option_index = 0; |
83 | c = getopt_long(argc, argv, "CdvVpc:", long_options, &option_index); | 85 | c = getopt_long(argc, argv, "hCdvVpc:", long_options, &option_index); |
84 | if (c == -1) { | 86 | if (c == -1) { |
85 | break; | 87 | break; |
86 | } | 88 | } |
87 | switch (c) { | 89 | switch (c) { |
88 | case 0: // Flag | 90 | case 0: // Flag |
89 | break; | 91 | break; |
92 | case 'h': // help | ||
93 | fprintf(stdout, "%s", usage); | ||
94 | exit(EXIT_SUCCESS); | ||
95 | break; | ||
90 | case 'c': // config | 96 | case 'c': // config |
91 | config_path = strdup(optarg); | 97 | config_path = strdup(optarg); |
92 | break; | 98 | break; |