> -----Original Message----- > From: Bruce Richardson <[email protected]> > Sent: Tuesday, December 5, 2023 8:21 PM > To: [email protected] > Cc: Sunil Kumar Kori <[email protected]>; [email protected]; > Bruce Richardson <[email protected]> > Subject: [EXT] [PATCH 1/3] buildtools/dpdk-cmdline-gen: support optional > parameters > > External Email > > ---------------------------------------------------------------------- > Sometimes a user may want to have a command which takes an optional > parameter. For commands with an optional constant string, this is no issue, > as it can be configured as two separate commands, e.g. > > start > start tx_first. > > However, if we want to have a variable parameter on the command, we hit > issues, because variable tokens do not form part of the generated > command names used for function and result-struct naming. To avoid > duplicate name issues, we add a special syntax to allow the user to > indicate that a particular variable parameter should be included in the > name. Any leading variable names starting with a "__" will be included in > command naming. > > This then allows us to have: > > start > start tx_first > start tx_first <UINT16>__n > > without hitting any naming conflicts. > It's a good option provided to user to choose name as per the need. I have another thought that how about providing flexibility to skip a token too along with implemented support. Consider following example: 1. ethdev <STRING>dev mtu <UINT16>size 2. ethdev <STRING>dev promiscuous <(on,off)>enable
So tokens and functions should be as cmd_ethdev_mtu_parsed() and cmd_ethdev_ promiscuous_parsed(). Here token <STRING>dev should be skipped. If it make sense, then please add this support too. > Signed-off-by: Bruce Richardson <[email protected]> > --- > buildtools/dpdk-cmdline-gen.py | 9 ++++++++- > doc/guides/prog_guide/cmdline.rst | 13 +++++++++++++ > 2 files changed, 21 insertions(+), 1 deletion(-) > > -- > 2.40.1

