[RFC,0/1] make cmdline library easier to use

Message ID 20230802170052.955323-1-bruce.richardson@intel.com (mailing list archive)
Headers
Series make cmdline library easier to use |

Message

Bruce Richardson Aug. 2, 2023, 5 p.m. UTC
  And now for something completely different... :-)

While it's nice that DPDK includes a commandline library for easily
adding interactivity to applications, the library itself is a little
clunky to use, due to the massive amounts of boilerplate definitions
required. Having used it recently on an app I was playing with for
testing, I decided the situation can potentially be improved with it
by use of a script to produce the boilerplate when given a simple
list of commands the user wants to add to the app.

This is the result of that effort. Sending it here as a rough-draft to
get feedback on whether this is worth including in DPDK itself.
Hopefully others may find it of use.

Bruce Richardson (1):
  cmdline/dpdk-cmdline-gen: generate boilerplate for simple cmds

 lib/cmdline/dpdk-cmdline-gen.py | 143 ++++++++++++++++++++++++++++++++
 1 file changed, 143 insertions(+)
 create mode 100755 lib/cmdline/dpdk-cmdline-gen.py

--
2.39.2
  

Comments

Stephen Hemminger Aug. 2, 2023, 6:05 p.m. UTC | #1
On Wed,  2 Aug 2023 18:00:51 +0100
Bruce Richardson <bruce.richardson@intel.com> wrote:

> And now for something completely different... :-)
> 
> While it's nice that DPDK includes a commandline library for easily
> adding interactivity to applications, the library itself is a little
> clunky to use, due to the massive amounts of boilerplate definitions
> required. Having used it recently on an app I was playing with for
> testing, I decided the situation can potentially be improved with it
> by use of a script to produce the boilerplate when given a simple
> list of commands the user wants to add to the app.
> 
> This is the result of that effort. Sending it here as a rough-draft to
> get feedback on whether this is worth including in DPDK itself.
> Hopefully others may find it of use.
> 
> Bruce Richardson (1):
>   cmdline/dpdk-cmdline-gen: generate boilerplate for simple cmds
> 
>  lib/cmdline/dpdk-cmdline-gen.py | 143 ++++++++++++++++++++++++++++++++
>  1 file changed, 143 insertions(+)
>  create mode 100755 lib/cmdline/dpdk-cmdline-gen.py

Ok, but this surely is a solved problem is some other open source library.
Or does every project reinvent this parsing?

Seems to me that something like bison/flex (ie yacc/lex) would be better
in terms of expressing the syntax separate from the implementation.
  
Bruce Richardson Aug. 3, 2023, 8:11 a.m. UTC | #2
On Wed, Aug 02, 2023 at 11:05:07AM -0700, Stephen Hemminger wrote:
> On Wed,  2 Aug 2023 18:00:51 +0100
> Bruce Richardson <bruce.richardson@intel.com> wrote:
> 
> > And now for something completely different... :-)
> > 
> > While it's nice that DPDK includes a commandline library for easily
> > adding interactivity to applications, the library itself is a little
> > clunky to use, due to the massive amounts of boilerplate definitions
> > required. Having used it recently on an app I was playing with for
> > testing, I decided the situation can potentially be improved with it
> > by use of a script to produce the boilerplate when given a simple
> > list of commands the user wants to add to the app.
> > 
> > This is the result of that effort. Sending it here as a rough-draft to
> > get feedback on whether this is worth including in DPDK itself.
> > Hopefully others may find it of use.
> > 
> > Bruce Richardson (1):
> >   cmdline/dpdk-cmdline-gen: generate boilerplate for simple cmds
> > 
> >  lib/cmdline/dpdk-cmdline-gen.py | 143 ++++++++++++++++++++++++++++++++
> >  1 file changed, 143 insertions(+)
> >  create mode 100755 lib/cmdline/dpdk-cmdline-gen.py
> 
> Ok, but this surely is a solved problem is some other open source library.
> Or does every project reinvent this parsing?
> 
> Seems to me that something like bison/flex (ie yacc/lex) would be better
> in terms of expressing the syntax separate from the implementation.

Sure, but it has been many, many years since I last even looked at those
tools, so it was faster for me to just use this python script for quick
cmdline generation when prototyping things! :-) I wanted something that
worked for me, so I'm just sharing it with the community in case others
find it useful.

If you have time, please do indeed come up with a lex/yacc generator
instead, it would indeed be a better solution. [If not, I suggest we take
what we can get if it works! :-)]

/Bruce