mirror of
https://github.com/swaywm/sway.git
synced 2024-11-26 09:51:29 +00:00
Merge pull request #269 from christophgysin/usage
Add --help to print usage
This commit is contained in:
commit
0af15cc19e
|
@ -17,6 +17,9 @@ Synopsis
|
||||||
Options
|
Options
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
*-h, --help*::
|
||||||
|
Show help message and quit.
|
||||||
|
|
||||||
*-c, \--config* <config>::
|
*-c, \--config* <config>::
|
||||||
Specifies a config file.
|
Specifies a config file.
|
||||||
|
|
||||||
|
|
35
sway/main.c
35
sway/main.c
|
@ -55,25 +55,41 @@ int main(int argc, char **argv) {
|
||||||
static int verbose = 0, debug = 0, validate = 0;
|
static int verbose = 0, debug = 0, validate = 0;
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"config", required_argument, NULL, 'c'},
|
{"config", required_argument, NULL, 'c'},
|
||||||
{"validate", no_argument, &validate, 1},
|
{"validate", no_argument, NULL, 'C'},
|
||||||
{"debug", no_argument, &debug, 1},
|
{"debug", no_argument, NULL, 'd'},
|
||||||
{"version", no_argument, NULL, 'v'},
|
{"version", no_argument, NULL, 'v'},
|
||||||
{"verbose", no_argument, &verbose, 1},
|
{"verbose", no_argument, NULL, 'V'},
|
||||||
{"get-socketpath", no_argument, NULL, 'p'},
|
{"get-socketpath", no_argument, NULL, 'p'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
char *config_path = NULL;
|
char *config_path = NULL;
|
||||||
|
|
||||||
|
const char* usage =
|
||||||
|
"Usage: sway [options] [command]\n"
|
||||||
|
"\n"
|
||||||
|
" -h, --help Show help message and quit.\n"
|
||||||
|
" -c, --config <config> Specify a config file.\n"
|
||||||
|
" -C, --validate Check the validity of the config file, then exit.\n"
|
||||||
|
" -d, --debug Enables full logging, including debug information.\n"
|
||||||
|
" -v, --version Show the version number and quit.\n"
|
||||||
|
" -V, --verbose Enables more verbose logging.\n"
|
||||||
|
" --get-socketpath Gets the IPC socket path and prints it, then exits.\n"
|
||||||
|
"\n";
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while (1) {
|
while (1) {
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
c = getopt_long(argc, argv, "CdvVpc:", long_options, &option_index);
|
c = getopt_long(argc, argv, "hCdvVpc:", long_options, &option_index);
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 0: // Flag
|
case 'h': // help
|
||||||
|
fprintf(stdout, "%s", usage);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
break;
|
break;
|
||||||
case 'c': // config
|
case 'c': // config
|
||||||
config_path = strdup(optarg);
|
config_path = strdup(optarg);
|
||||||
|
@ -90,7 +106,7 @@ int main(int argc, char **argv) {
|
||||||
#else
|
#else
|
||||||
fprintf(stdout, "version not detected\n");
|
fprintf(stdout, "version not detected\n");
|
||||||
#endif
|
#endif
|
||||||
exit(0);
|
exit(EXIT_SUCCESS);
|
||||||
break;
|
break;
|
||||||
case 'V': // verbose
|
case 'V': // verbose
|
||||||
verbose = 1;
|
verbose = 1;
|
||||||
|
@ -98,12 +114,15 @@ int main(int argc, char **argv) {
|
||||||
case 'p': ; // --get-socketpath
|
case 'p': ; // --get-socketpath
|
||||||
if (getenv("SWAYSOCK")) {
|
if (getenv("SWAYSOCK")) {
|
||||||
fprintf(stdout, "%s\n", getenv("SWAYSOCK"));
|
fprintf(stdout, "%s\n", getenv("SWAYSOCK"));
|
||||||
exit(0);
|
exit(EXIT_SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "sway socket not detected.\n");
|
fprintf(stderr, "sway socket not detected.\n");
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "%s", usage);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ void sway_terminate(void) {
|
||||||
}
|
}
|
||||||
list_free(surfaces);
|
list_free(surfaces);
|
||||||
registry_teardown(registry);
|
registry_teardown(registry);
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char **argv) {
|
int main(int argc, const char **argv) {
|
||||||
|
|
|
@ -20,6 +20,9 @@ ImageMagick convert for processing.
|
||||||
Options
|
Options
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
*-h, --help*::
|
||||||
|
Show help message and quit.
|
||||||
|
|
||||||
*-c, \--capture*::
|
*-c, \--capture*::
|
||||||
Captures multiple frames as video and passes them into ffmpeg. Continues until
|
Captures multiple frames as video and passes them into ffmpeg. Continues until
|
||||||
you send SIGTERM (ctrl+c) to swaygrab.
|
you send SIGTERM (ctrl+c) to swaygrab.
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include "ipc-client.h"
|
#include "ipc-client.h"
|
||||||
|
|
||||||
void sway_terminate(void) {
|
void sway_terminate(void) {
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int numlen(int n) {
|
int numlen(int n) {
|
||||||
|
@ -127,24 +127,33 @@ int main(int argc, char **argv) {
|
||||||
init_log(L_INFO);
|
init_log(L_INFO);
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"capture", no_argument, &capture, 'c'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
|
{"capture", no_argument, NULL, 'c'},
|
||||||
{"version", no_argument, NULL, 'v'},
|
{"version", no_argument, NULL, 'v'},
|
||||||
{"socket", required_argument, NULL, 's'},
|
{"socket", required_argument, NULL, 's'},
|
||||||
{"raw", no_argument, &raw, 'r'},
|
{"raw", no_argument, NULL, 'r'},
|
||||||
{"rate", required_argument, NULL, 'R'},
|
{"rate", required_argument, NULL, 'R'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char *usage =
|
||||||
|
"Usage: swaygrab [options] <output> [file]\n"
|
||||||
|
"\n"
|
||||||
|
" -h, --help Show help message and quit.\n"
|
||||||
|
" -c, --capture Capture video.\n"
|
||||||
|
" -v, --version Show the version number and quit.\n"
|
||||||
|
" -s, --socket <socket> Use the specified socket.\n"
|
||||||
|
" -R, --rate <rate> Specify framerate (default: 30)\n"
|
||||||
|
" -r, --raw Write raw rgba data to stdout.\n";
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while (1) {
|
while (1) {
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
c = getopt_long(argc, argv, "cvs:r", long_options, &option_index);
|
c = getopt_long(argc, argv, "hcvs:r", long_options, &option_index);
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 0: // Flag
|
|
||||||
break;
|
|
||||||
case 's': // Socket
|
case 's': // Socket
|
||||||
socket_path = strdup(optarg);
|
socket_path = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
@ -163,8 +172,11 @@ int main(int argc, char **argv) {
|
||||||
#else
|
#else
|
||||||
fprintf(stdout, "version not detected\n");
|
fprintf(stdout, "version not detected\n");
|
||||||
#endif
|
#endif
|
||||||
exit(0);
|
exit(EXIT_SUCCESS);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "%s", usage);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,9 @@ Synopsis
|
||||||
Options
|
Options
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
*-h, --help*::
|
||||||
|
Show help message and quit.
|
||||||
|
|
||||||
*-q, \--quiet*::
|
*-q, \--quiet*::
|
||||||
Sends the IPC message but does not print the response from sway.
|
Sends the IPC message but does not print the response from sway.
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
void sway_terminate(void) {
|
void sway_terminate(void) {
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
@ -23,22 +23,33 @@ int main(int argc, char **argv) {
|
||||||
init_log(L_INFO);
|
init_log(L_INFO);
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"quiet", no_argument, &quiet, 'q'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
|
{"quiet", no_argument, NULL, 'q'},
|
||||||
{"version", no_argument, NULL, 'v'},
|
{"version", no_argument, NULL, 'v'},
|
||||||
{"socket", required_argument, NULL, 's'},
|
{"socket", required_argument, NULL, 's'},
|
||||||
{"type", required_argument, NULL, 't'},
|
{"type", required_argument, NULL, 't'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char *usage =
|
||||||
|
"Usage: swaymsg [options] [message]\n"
|
||||||
|
"\n"
|
||||||
|
" -h, --help Show help message and quit.\n"
|
||||||
|
" -q, --quiet Be quiet.\n"
|
||||||
|
" -v, --version Show the version number and quit.\n"
|
||||||
|
" -s, --socket <socket> Use the specified socket.\n"
|
||||||
|
" -t, --type <type> Specify the message type.\n";
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while (1) {
|
while (1) {
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
c = getopt_long(argc, argv, "qvs:t:", long_options, &option_index);
|
c = getopt_long(argc, argv, "hqvs:t:", long_options, &option_index);
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 0: // Flag
|
case 'q': // Quiet
|
||||||
|
quiet = 1;
|
||||||
break;
|
break;
|
||||||
case 's': // Socket
|
case 's': // Socket
|
||||||
socket_path = strdup(optarg);
|
socket_path = strdup(optarg);
|
||||||
|
@ -52,8 +63,11 @@ int main(int argc, char **argv) {
|
||||||
#else
|
#else
|
||||||
fprintf(stdout, "version not detected\n");
|
fprintf(stdout, "version not detected\n");
|
||||||
#endif
|
#endif
|
||||||
exit(0);
|
exit(EXIT_SUCCESS);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "%s", usage);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue