From e6398674b0d16c399b4becefdf0ddb8842b443d2 Mon Sep 17 00:00:00 2001 From: mwalker33 Date: Sat, 3 Oct 2020 19:06:01 +1000 Subject: [PATCH] Cliparser cleanup Update to remove "=" from help text update md file, fix typos and better notses for the options. --- client/deps/cliparser/argtable3.c | 7 ++++++- doc/cliparser.md | 35 ++++++++++++++++++------------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/client/deps/cliparser/argtable3.c b/client/deps/cliparser/argtable3.c index f0b6a4d37..134c82306 100644 --- a/client/deps/cliparser/argtable3.c +++ b/client/deps/cliparser/argtable3.c @@ -4270,10 +4270,15 @@ static void arg_cat_optionv(char *dest, } if (datatype) { - if (longopts) +/* if (longopts) arg_cat(&dest, "=", &ndest); else if (shortopts) arg_cat(&dest, " ", &ndest); +*/ + if (longopts) + arg_cat(&dest, " ", &ndest); + else if (shortopts) + arg_cat(&dest, " ", &ndest); if (optvalue) { arg_cat(&dest, "[", &ndest); diff --git a/doc/cliparser.md b/doc/cliparser.md index bbc6c6b42..430583523 100644 --- a/doc/cliparser.md +++ b/doc/cliparser.md @@ -28,11 +28,11 @@ It will also add the `-h --help` option automatic. ## design comments -* where possiable all options should be lowercase. -* extended options preceeded with -- should be short +* where possible all options should be lowercase. +* extended options preceded with -- should be short * options provided directly (without an option identifier) should be avoided. -* -vv for extra verbos should be avoided; use of debug level is prefered. -* with --options the equal is not needed (will work with and without) so dont use '=' +* -vv for extra verbos should be avoided; use of debug level is preferred. +* with --options the equal is not needed (will work with and without) so don't use '=' e.g. cmd --cn 12345 @@ -62,10 +62,10 @@ In the command function, setup the context CLIParserContext *ctx; -### define the text +### define the context CLIParserInit (\, \, \); -use -> to seperate example and example comment and \\n to seperate examples. +use -> to separate example and example comment and \\n to separate examples. e.g. lf indala clone -r a0000000a0002021 -> this uses ..... CLIParserInit(&ctx, "lf indala clone", @@ -92,21 +92,28 @@ _All options has a parameter index, since `-h --help` is added automatic, it wi Hence all options you add will start at index 1 and upwards._ **Notes:** -booleen : arg_lit0 ("\", "\", \["\",\] \<"description"\>) +**bool option. true if supplied** +bool : arg_lit0 ("\", "\", \["\",\] \<"description"\>) -**integer** - optional integer : arg_int0 ("\", "\", \["\",\] \<"description"\>)\ +**integer that is optional** + optional integer : arg_int0 ("\", "\", \["\",\] \<"description"\>) + +**integer that is required** required integer : arg_int1 ("\", "\", \["\",\] \<"description"\>) -**Strings 0 or 1** - optional string : arg_str0("\", "\", \["\",\] \<"description"\>)\ +**String option that is optional and only one instance can be provided** + optional string : arg_str0("\", "\", \["\",\] \<"description"\>) + +**String option that is required and only one instance can be provided** required string : arg_str1("\", "\", \["\",\] \<"description"\>) -**Strings x to 250** - optional string : arg_strx0 ("\", "\", \["\",\] \<"description"\>)\ +**String option that is optional and can have up to 250 instances provided** + optional string : arg_strx0 ("\", "\", \["\",\] \<"description"\>) + +**String option that is required/at least one instance and can have up to 250 instances** required string : arg_strx1 ("\", "\", \["\",\] \<"description"\>) -**if an option does not have a short or long option, use NULL in its place** +**if an option does not have a short or long option, use NULL in its place** ### show the menu CLIExecWithReturn(\, \, \, \);