hdt: Implement exit with the new cli framework; Cleanups
Impact: Cleanups, add the concept of 1 word commands, make hdt_cli global
Add support for one token commands. Each mode can now have "default
commands", which are commands made of only one word.
Some of these are generic (exit, help, ...). They are stored in the
hdt mode structures. Only 'exit' is implemented so far.
Note: this is different from default callbacks for modules:
dmi> exit # default command (shared, stored into
# hdt structures)
dmi> show chassis # will execute the chassis module
# callback stored in the show modules
# list of the dmi mode
dmi> show # will execute the default callback for the
# show modules
The structure is the following:
|
----> mode A
| |
| ------> default_modules
| | |
| | ----> module default
| | |
| | ----> module a
| | |
| | ----> module b
| |
| ------> show_modules
| |
| ----> module default
| |
| ----> module c
| |
| ----> module d
| |
| ----> module e
If A is dmi, c is cpu, d memory, e chassis, etc and default (of
show_modules) displays a summary (command 'show'). a and b are single
commands ('foo', 'bar'). 'exit', 'help', ... fall into that category but are
defined in the hdt mode.
Note2: none of the modules list is mandatory. Most of the time actually,
the default_modules list will be empty.
Misc: Refactor the new framework by extracting logic into helpers.
Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>