[PATCH v4 0/7] document and simplify use of cmdline
Bruce Richardson
bruce.richardson at intel.com
Wed Oct 18 13:37:01 CEST 2023
On Wed, Oct 18, 2023 at 01:21:40PM +0200, David Marchand wrote:
> Hello Bruce,
>
>
> On Tue, Oct 17, 2023 at 7:08 PM Bruce Richardson
> <bruce.richardson at intel.com> wrote:
> > > > sure I like it that much as a feature :-) I rather like having unique
> > > > prefixes for each command. I wasn't actually aware of the testpmd "help
> > > > <section>" command at all. I will have to look into it.
> > >
> > > Let me propose an alternative hack.
> > > I mentionned previously that we could have a better namespace /
> > > discriminant for those symbols, and it seems easier than I thought:
> > >
> > > @@ -25,8 +25,10 @@ def process_command(tokens, cfile, comment):
> > > sys.exit(1)
> > > for t in tokens:
> > > if t.startswith('<'):
> > > - break
> > > - name.append(t)
> > > + t_type, t_name = t[1:].split('>')
> > > + name.append(t_name)
> > > + else:
> > > + name.append(t)
> > > name = '_'.join(name)
> > >
> > > result_struct = []
> > >
> > > With this, any command implementation symbol has the full chain of
> > > token names as a prefix which will ensure there is no conflict.
> > > WDYT?
> > >
> > Having thought a little more about it, I still don't like having the full
> > command in all cases, but I can see it being useful for cases of
> > overlapping prefixes.
> >
> > How about making it optional - setting a flag in the typename, or in the
> > parameter name to indicate that it should be included in the overall
> > command name. For example, if we prefix the variable name with "_" or "__",
> > it could indicate that we can choose to include this.
> >
> > show port <UINT16>n --> void cmd_show_port_parsed(...)
> > show port <UINT16>_n --> void cmd_show_port_n_parsed(...)
> >
>
> I think I get what you mean, and it seems acceptable.
>
Cool. Any suggestions for a preferred prefix to indicate inclusion in the
cmd name? "_", "__" or something else? I'm trending towards single "_" as
above.
>
> > Prefixes on strings beyond initial tokens could just be silently stripped.
>
> By initial tokens, do you mean fixed strings token before a <> typed token ?
>
Yes.
So:
add <UINT16>x --> cmd_add_parsed
add <UINT16>_x --> cmd_add_x_parsed
add <UINT16>_x <UINT16>_y --> cmd_add_x_y_parsed
add <UINT16>x <UINT16>_y --> cmd_add_parsed, strip "_" off y silently
/Bruce
More information about the dev
mailing list