DPDK patches and discussions
 help / color / mirror / Atom feed
From: Olivier MATZ <olivier.matz@6wind.com>
To: Igor Ryzhov <iryzhov@arccn.ru>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] Question about librte_cmdline
Date: Fri, 14 Nov 2014 12:14:00 +0100	[thread overview]
Message-ID: <5465E3F8.5070606@6wind.com> (raw)
In-Reply-To: <D12B450C-961B-4BF7-9D81-AC8F69DF3E55@arccn.ru>

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@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

  reply	other threads:[~2014-11-14 11:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-14  8:52 Igor Ryzhov
2014-11-14 11:14 ` Olivier MATZ [this message]
2014-11-14 11:47   ` Igor Ryzhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5465E3F8.5070606@6wind.com \
    --to=olivier.matz@6wind.com \
    --cc=dev@dpdk.org \
    --cc=iryzhov@arccn.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).