From ae5355aefd9d75fb6183f9996b2794ea1f3a373a Mon Sep 17 00:00:00 2001 From: merlokk Date: Tue, 28 Nov 2017 14:40:15 +0200 Subject: [PATCH] added samples to command's help --- client/cliparser/cliparser.c | 8 ++++++-- client/cliparser/cliparser.h | 2 +- client/cmdhf14a.c | 18 +++++++----------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/client/cliparser/cliparser.c b/client/cliparser/cliparser.c index 09c8f189..0e70a630 100644 --- a/client/cliparser/cliparser.c +++ b/client/cliparser/cliparser.c @@ -16,13 +16,15 @@ void **argtable = NULL; size_t argtableLen = 0; char *programName = NULL; char *programHint = NULL; +char *programHelp = NULL; char buf[500] = {0}; -int CLIParserInit(char *vprogramName, char *vprogramHint) { +int CLIParserInit(char *vprogramName, char *vprogramHint, char *vprogramHelp) { argtable = NULL; argtableLen = 0; programName = vprogramName; programHint = vprogramHint; + programHelp = vprogramHelp; memset(buf, 0x00, 500); return 0; @@ -49,8 +51,10 @@ int CLIParserParseArg(int argc, char **argv, void* vargtable[], size_t vargtable arg_print_syntaxv(stdout, argtable, "\n"); if (programHint) printf("%s\n\n", programHint); - arg_print_glossary(stdout, argtable, " %-19s %s\n"); + arg_print_glossary(stdout, argtable, " %-20s %s\n"); printf("\n"); + if (programHelp) + printf("%s \n", programHelp); return 1; } diff --git a/client/cliparser/cliparser.h b/client/cliparser/cliparser.h index 4156b19c..8548c8b9 100644 --- a/client/cliparser/cliparser.h +++ b/client/cliparser/cliparser.h @@ -19,7 +19,7 @@ #define arg_get_str(n)(((struct arg_str*)argtable[n])) #define arg_get_int(n)(((struct arg_int*)argtable[n])) -extern int CLIParserInit(char *vprogramName, char *vprogramHint); +extern int CLIParserInit(char *vprogramName, char *vprogramHint, char *vprogramHelp); extern int CLIParserParseString(const char* str, void* argtable[], size_t vargtableLen, bool allowEmptyExec); extern int CLIParserParseArg(int argc, char **argv, void* argtable[], size_t vargtableLen, bool allowEmptyExec); extern void CLIParserFree(); diff --git a/client/cmdhf14a.c b/client/cmdhf14a.c index 036fbefe..493c5f86 100644 --- a/client/cmdhf14a.c +++ b/client/cmdhf14a.c @@ -135,7 +135,7 @@ int CmdHF14AReader(const char *Cmd) { uint32_t cm = ISO14A_CONNECT; bool leaveSignalON = false; - CLIParserInit("hf 14a reader", "Executes ISO1443A anticollision-select group of commands."); + CLIParserInit("hf 14a reader", "Executes ISO1443A anticollision-select group of commands.", NULL); void* argtable[] = { arg_param_begin, arg_lit0("kK", "keep", "keep the field active after command executed"), @@ -721,15 +721,8 @@ int CmdHF14AAPDU(const char *cmd) { bool leaveSignalON = false; bool decodeTLV = false; - CLIParserInit("hf 14a apdu", "Send ISO 14443-4 APDU to tag"); - /*struct arg_lit *ahelp = arg_lit0("hH", "help", "print this help and exit"); - struct arg_lit *as = arg_lit0("sS", "select", "activate field and select card"); - struct arg_lit *ak = arg_lit0("kK", "keep", "leave the signal field ON after receive response"); - struct arg_lit *at = arg_lit0("tT", "tlv", "executes TLV decoder if it possible"); - struct arg_str *astr = arg_str1(NULL, NULL, "", NULL); - struct arg_end *aend = arg_end(20); - void* argtable[] = {ahelp, as, ak, at, astr, aend}; - */ + CLIParserInit("hf 14a apdu", "Send ISO 14443-4 APDU to tag", "Sample:\n\thf 14a apdu -st 00A404000E325041592E5359532E444446303100\n"); + void* argtable[] = { arg_param_begin, arg_lit0("sS", "select", "activate field and select card"), @@ -790,7 +783,10 @@ int CmdHF14ACmdRaw(const char *cmd) { int datalen = 0; // extract parameters - CLIParserInit("hf 14a raw", "Send raw hex data to tag"); + CLIParserInit("hf 14a raw", "Send raw hex data to tag", + "Sample:\n"\ + "\thf 14a raw -pa -b7 -t1000 52 -- execute WUPA\n"\ + "\thf 14a raw -p 9320 -- anticollision\n"); void* argtable[] = { arg_param_begin, arg_lit0("rR", "nreply", "do not read response"),