From 257490366b9c101910f34f9646afc71adf5a85fb Mon Sep 17 00:00:00 2001 From: Peter Oberparleiter Date: Fri, 24 Aug 2018 09:50:01 +0100 Subject: [PATCH] util_prg_example: Add --help and --version options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add missing long options for --help and --version in util_prg_example. Signed-off-by: Peter Oberparleiter Signed-off-by: Jan Höppner --- libutil/util_prg_example.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libutil/util_prg_example.c b/libutil/util_prg_example.c index 6595c314..674cec35 100644 --- a/libutil/util_prg_example.c +++ b/libutil/util_prg_example.c @@ -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();