diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2013-08-07 11:05:57 +1000 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2013-08-07 16:24:44 -0700 |
commit | 2d1ed470d946ca8f8b988e3d11f642e85fa0a290 (patch) | |
tree | 7c55f2b49627056a51231a109d4848772e6507ec | |
parent | 81555350affea0a7fba5894116b1ec178ac53827 (diff) |
scanner: support help and --help
wayland-scanner without arguments prints out usage. With help or --help it
waits for stdin to supply something which isn't quite as informative as
printing out the help.
This patch also moves the strcmp for args up to have all of them in one
location.
-rw-r--r-- | src/scanner.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/scanner.c b/src/scanner.c index 4aa70d1..ace6633 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -1158,9 +1158,22 @@ int main(int argc, char *argv[]) struct protocol protocol; int len; void *buf; + enum { + CLIENT_HEADER, + SERVER_HEADER, + CODE, + } mode; if (argc != 2) usage(EXIT_FAILURE); + else if (strcmp(argv[1], "help") == 0 || strcmp(argv[1], "--help") == 0) + usage(EXIT_SUCCESS); + else if (strcmp(argv[1], "client-header") == 0) + mode = CLIENT_HEADER; + else if (strcmp(argv[1], "server-header") == 0) + mode = SERVER_HEADER; + else if (strcmp(argv[1], "code") == 0) + mode = CODE; wl_list_init(&protocol.interface_list); protocol.type_index = 0; @@ -1193,12 +1206,16 @@ int main(int argc, char *argv[]) XML_ParserFree(ctx.parser); - if (strcmp(argv[1], "client-header") == 0) { - emit_header(&protocol, 0); - } else if (strcmp(argv[1], "server-header") == 0) { - emit_header(&protocol, 1); - } else if (strcmp(argv[1], "code") == 0) { - emit_code(&protocol); + switch(mode) { + case CLIENT_HEADER: + emit_header(&protocol, 0); + break; + case SERVER_HEADER: + emit_header(&protocol, 1); + break; + case CODE: + emit_code(&protocol); + break; } return 0; |