Hi Igor, Adding-back the list to the discussion, I removed it by mistake in my first answer.
>> 14 ????. 2014 ?., ? 12:20, Olivier MATZ <olivier.matz at 6wind.com> >> ???????(?): >> >> Hi Igor, >> >> On 11/14/2014 09:52 AM, Igor Ryzhov wrote: >>> Are there any docs with detailed description of cmdline library? >>> I found only some information in ?DPDK Sample Apps? document, but it >>> describes only a couple of features. >> >> In my knowledge, there is no such documentation. >> You can also refer to testpmd that gives a lot of different commands. >> >> If you have any question, you can ask on the list. >> >> Regards, >> Olivier > > Thank you, I?ll check testpmd. > > At the moment I have a question - is there a possibility to have optional > tokens in one command? > > For example: > > I have one command - ?object? and two subcommands - ?add? and ?del?: > > object add name IP > object del name > > And the question is - can I have just one context instruction for this? > Something like that: > > Result struct: > > struct object_result { > cmdline_fixed_string_t object; > cmdline_fixed_string_t cmd; > cmdline_fixed_string_t name; > cmdline_ipaddr_t ip; // I need it optional - only > for ?add? case > } > > And tokens: > > cmdline_parse_token_string_t object = > TOKEN_STRING_INITIALIZER(struct object_result, object, "object"); > cmdline_parse_token_string_t cmd = > TOKEN_STRING_INITIALIZER(struct object_result, cmd, "add#del"); > cmdline_parse_token_string_t name = > TOKEN_STRING_INITIALIZER(struct object_result, name, NULL); > cmdline_parse_token_ipaddr_t ip = > TOKEN_IPV4_INITIALIZER(struct object_result, ip, NULL); > > As I understand investigating the code of sample application - all tokens are > required (because there are two different instructions - for ?add? and for > ?del/show?). > And in this example configuration there is no possibility for string ?object > del name? without last IP token. > So I need to have two different context instructions - one for ?add? and one > for ?del?. > Am I right? Right, there is no way to declare an optional token in one instruction. But if there are few case (ex: a "set" and a "show" intructions), you can factorize the structure and the callback function. There is an example in my latest TSO patch: http://dpdk.org/ml/archives/dev/2014-November/007962.html Regards, Olivier