[cli] simplify dataset commands (#9366)

This commit simplifies the `Cli::Dataset` implementation by defining
an array of `ComponentMapper` structures. Each `ComponentMapper`
structure corresponds to a Dataset component, and provides the
following information:
- The component's CLI name
- A method pointer to output that component
- A method pointer to parse that component
- A pointer to the component's mIsPresent boolean flag

A new `LookupMapper()` method allows us to find (using binary search)
the entry corresponding to a given component name. This model allows
us to reuse code patterns for the main dataset sub-commands,
`mgmtsetcommand`, and `mgmtgetcommand` commands when outputting or
parsing dataset components.
This commit is contained in:
Abtin Keshavarzian
2023-08-23 14:30:30 -07:00
committed by GitHub
parent 9dd3f2005b
commit c10f650468
4 changed files with 599 additions and 745 deletions
+539 -731
View File
File diff suppressed because it is too large Load Diff