DPDK patches and discussions
 help / color / mirror / Atom feed
From: Igor Ryzhov <iryzhov@arccn.ru>
To: Olivier MATZ <olivier.matz@6wind.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] Question about librte_cmdline
Date: Fri, 14 Nov 2014 14:47:14 +0300	[thread overview]
Message-ID: <CB8BF662-E30E-4913-94FE-62A1699D50D3@arccn.ru> (raw)
In-Reply-To: <5465E3F8.5070606@6wind.com>

Thank you.

That’s not a really big problem that we need it’s own structure for every command, but the lack of optional parameters is a problem.

For example:
	object add IP [port]

	it’s just one command, but we need two different structures - with and without «port»

Maybe I’ll work on it sometime later.

> 14 нояб. 2014 г., в 14:14, Olivier MATZ <olivier.matz@6wind.com> написал(а):
> 
> 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:37 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
2014-11-14 11:47   ` Igor Ryzhov [this message]

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=CB8BF662-E30E-4913-94FE-62A1699D50D3@arccn.ru \
    --to=iryzhov@arccn.ru \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.com \
    /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).