From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id D1D697E75 for ; Fri, 14 Nov 2014 12:04:07 +0100 (CET) Received: from was59-1-82-226-113-214.fbx.proxad.net ([82.226.113.214] helo=[192.168.0.10]) by mail.droids-corp.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1XpEsK-0006nM-PU; Fri, 14 Nov 2014 12:17:16 +0100 Message-ID: <5465E3F8.5070606@6wind.com> Date: Fri, 14 Nov 2014 12:14:00 +0100 From: Olivier MATZ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.5.0 MIME-Version: 1.0 To: Igor Ryzhov , "dev@dpdk.org" References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] Question about librte_cmdline X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Nov 2014 11:04:07 -0000 Hi Igor, Adding-back the list to the discussion, I removed it by mistake in my first answer. >> 14 нояб. 2014 г., в 12:20, Olivier MATZ написал(а): >> >> 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