Mercurial > hg > piper-cpp
comparison vamp-server/simple-server.cpp @ 279:b7eec400cd94
Support long options as well
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Thu, 01 Nov 2018 14:04:58 +0000 |
parents | 50e3c02c11cc |
children | c0b29d2af155 |
comparison
equal
deleted
inserted
replaced
278:71b166bcbcc3 | 279:b7eec400cd94 |
---|---|
89 " Usage: " << myname << " [-d] <format>\n" | 89 " Usage: " << myname << " [-d] <format>\n" |
90 " " << myname << " -v\n" | 90 " " << myname << " -v\n" |
91 " " << myname << " -h\n\n" | 91 " " << myname << " -h\n\n" |
92 " where\n" | 92 " where\n" |
93 " <format>: the format to read and write messages in (\"json\" or \"capnp\")\n" | 93 " <format>: the format to read and write messages in (\"json\" or \"capnp\")\n" |
94 " -d: also print debug information to stderr\n" | 94 " -d, --debug: also print debug information to stderr\n" |
95 " -v: print version number to stdout and exit\n" | 95 " -v, --version: print version number to stdout and exit\n" |
96 " -h: print this text to stderr and exit\n\n" | 96 " -h, --help: print this text to stderr and exit\n\n" |
97 "Expects Piper request messages in either Cap'n Proto or JSON format on stdin,\n" | 97 "Expects Piper request messages in either Cap'n Proto or JSON format on stdin,\n" |
98 "and writes response messages in the same format to stdout.\n\n" | 98 "and writes response messages in the same format to stdout.\n\n" |
99 "This server is intended for simple process separation. It's only suitable for\n" | 99 "This server is intended for simple process separation. It's only suitable for\n" |
100 "use with a single trusted client per server invocation.\n\n" | 100 "use with a single trusted client per server invocation.\n\n" |
101 "The two formats behave differently in case of parser errors. JSON messages are\n" | 101 "The two formats behave differently in case of parser errors. JSON messages are\n" |
637 } | 637 } |
638 | 638 |
639 bool debug = false; | 639 bool debug = false; |
640 | 640 |
641 string arg = argv[1]; | 641 string arg = argv[1]; |
642 if (arg == "-h") { | 642 if (arg == "-h" || arg == "--help") { |
643 if (argc == 2) { | 643 if (argc == 2) { |
644 usage(true); | 644 usage(true); |
645 } else { | 645 } else { |
646 usage(); | 646 usage(); |
647 } | 647 } |
648 } else if (arg == "-v") { | 648 } else if (arg == "-v" || arg == "--version") { |
649 if (argc == 2) { | 649 if (argc == 2) { |
650 version(); | 650 version(); |
651 } else { | 651 } else { |
652 usage(); | 652 usage(); |
653 } | 653 } |
654 } else if (arg == "-d") { | 654 } else if (arg == "-d" || arg == "--debug") { |
655 if (argc == 2) { | 655 if (argc == 2) { |
656 usage(); | 656 usage(); |
657 } else { | 657 } else { |
658 debug = true; | 658 debug = true; |
659 arg = argv[2]; | 659 arg = argv[2]; |