util_prg_example: Add --help and --version options

Add missing long options for --help and --version in util_prg_example.

Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Peter Oberparleiter
2018-08-24 09:50:01 +01:00
committed by Jan Höppner
parent 5ef1320a7b
commit 257490366b

View File

@@ -34,6 +34,12 @@ const struct util_prg prg = {
}
};
static const struct option opt_list[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'v' },
{ NULL, no_argument, NULL, 0 },
};
/*
* Demonstrate the util_prg_print() functions
*/
@@ -49,7 +55,7 @@ int main(int argc, char *argv[])
util_prg_init(&prg);
while ((opt = getopt(argc, argv, "vhe")) != -1) {
while ((opt = getopt_long(argc, argv, "vhe", opt_list, NULL)) != -1) {
switch (opt) {
case 'v':
util_prg_print_version();