From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58]) by dpdk.org (Postfix) with ESMTP id 8933C58EE for ; Mon, 3 Nov 2014 16:57:06 +0100 (CET) Received: from rrcs-67-52-130-29.west.biz.rr.com ([67.52.130.29] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1XlK8v-00009A-1r; Mon, 03 Nov 2014 11:06:14 -0500 Date: Mon, 3 Nov 2014 11:06:02 -0500 From: Neil Horman To: "Wiles, Roger Keith" Message-ID: <20141103160602.GA6625@localhost.localdomain> References: <1414967308-69530-1-git-send-email-keith.wiles@windriver.com> <20141103104129.GA4840@bricha3-MOBL3> <307F2C60-7638-40C8-A9BC-DC3EE3D59F8C@windriver.com> <20141103141658.GA6964@bricha3-MOBL3> <7D39110F-D305-4C48-8BD6-37F6DCD2E434@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7D39110F-D305-4C48-8BD6-37F6DCD2E434@windriver.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Score: -2.9 (--) X-Spam-Status: No Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH] Add external parser support for unknown commands. 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: Mon, 03 Nov 2014 15:57:06 -0000 On Mon, Nov 03, 2014 at 02:25:51PM +0000, Wiles, Roger Keith wrote: > > > On Nov 3, 2014, at 8:16 AM, Bruce Richardson wrote: > > > > On Mon, Nov 03, 2014 at 02:08:46PM +0000, Wiles, Roger Keith wrote: > >> > >>> On Nov 3, 2014, at 4:41 AM, Bruce Richardson wrote: > >>> > >>> On Sun, Nov 02, 2014 at 04:28:28PM -0600, Keith Wiles wrote: > >>>> Allow for a external parser to handle the command line if the > >>>> command is not found and the developer has called the routine > >>>> int cmdline_set_external_parser(struct cmdline * cl, > >>>> cmdline_external_parser_t parser); > >>>> function to set the function pointer. > >>>> > >>>> The function for the external parser function should return CMDLINE_PARSE_NOMATCH > >>>> if not able to match the command requested or zero is handled. > >>>> > >>>> Prototype of external routine: > >>>> int (*cmdline_external_parser_t)(struct cmdline * cl, const char * buy); > >>>> > >>>> Signed-off-by: Keith Wiles > >>> > >>> Hi Keith, > >>> > >>> what is the expected use case for this? Is it for embedding other programming languages alongside the existing DPDK command-line or some other purpose? [Perhaps the use case could be called out in the patch description] > >> > >> Hi Bruce, > >> > >> I guess the external parser could be used for other programming languages, but the case I was looking at was to provide a default escape from the command line parser to allow my application to handle the commands not understood by the parser. Now that you point it out I could use something like ‘%’ to execute a single line of script code, which is a good idea (thanks). > >> > >> One case I am looking at is when you want to execute a command and do not want to add the support into the commands.c file for every possible command. Take the case where you have a bunch of scripts (Lua) in a directory much like a bin directory. Then you could type foo.lua or foo on the command line and execute the foo.lua having the application detect you want to load and run a Lua script after it has finished parsing for the builtin commands. > >> > >> For Pktgen I had to add a command called ‘run ’ to support running a script with arguments. I also needed to add a argvlist type to cmdline to not error out on that command and split up the args into a argv list like format. (Maybe I need to submit that code??) It seemed more straight forward to just pass the command line to the application to run the command. I understand that seems like a minor point, but it does make it easier to use and to support the features I want to support in my PoC. > >> > >> Using this method you can just type the name instead of something like ‘run foo.lua’ or just ‘run foo’ and let the code figure out what to run. I have more plans for this features as well and have not finished the basic PoC yet. If you want a peek I can show you what I am working on currently. > >> > >> Does this help and do I really need to add all of this to the commit message :-) > >> > > Thanks for the explanation. However, if you are looking to have the application handle a bunch of commands itself, why does it need to use the commandline library at all? Why not just have the app handle all the commands instead of some of them? > > I guess that would be reasonable, but then I would have to add support for all of the command line parsing being done in the cmdline code. Think of this as a default case for the parser and to me that makes more sense then just doing my own command line design. In the cmdline code you guys provided is a lot of features like history, control key support, arg parsing (IP, MAC) and many others. I would rather not have to write that code myself. > > The default case is the same behavior today, with giving a no match error unless they add the external parser. It seems alot simpler than that to me. Looking at the test applications, the command line parser expects the application to create an array of cmdline_parse_ctx_t structures to support new option parsing. If your goal is to support other languages, it seems to make more sense to just use foreign language bindings to merge your coding language support with the DPDK (ostensibly you will already have to do that if you want to use other parts of the DPDK). Am I missing something? Neil > > > > /Bruce > > Keith Wiles, Principal Technologist with CTO office, Wind River mobile 972-213-5533 >