[pve-devel] [PATCH common v4 0/3] CLI: Sub-commands and aliases
Philip Abernethy
p.abernethy at proxmox.com
Mon Oct 16 09:50:15 CEST 2017
This patch (1/3 is the effective part) adds support for sub-commands in
the form of `pveum user add <userid>`, as well as aliases, so the prior
format can still be used. It correctly parses the current command format
as well and, to my knowledge,generates identical help texts, man-pages
and html-docs.
It supports arbitrary sub-command depths and command aliases are
excluded from the history:
# pveum help
USAGE: pveum <COMMAND> [ARGS] [OPTIONS]
pveum acl delete <path> --roles <string> [OPTIONS]
pveum acl modify <path> --roles <string> [OPTIONS]
pveum group add <groupid> [OPTIONS]
pveum group delete <groupid>
pveum group modify <groupid> [OPTIONS]
pveum role add <roleid> [OPTIONS]
pveum role delete <roleid>
pveum role modify <roleid> --privs <string> [OPTIONS]
pveum this is some really long command <roleid> [OPTIONS]
pveum user add <userid> [OPTIONS]
pveum user delete <userid>
pveum user modify <userid> [OPTIONS]
pveum passwd <userid>
pveum ticket <username> [OPTIONS]
pveum help [<cmd>] [OPTIONS]
However they will still produce an entry in the man-page and html doc:
$ man pveum
[…]
pveum aclmod
An alias for pveum acl modify.
[…]
Completion works for the help as well as for actual execution in
sub-commands, aliases or classic commands alike:
# pveum help roled
USAGE: pveum role delete <roleid>
[…]
# pveum help role a
USAGE: pveum role add <roleid> [OPTIONS]
[…]
# pveum help ti
USAGE: pveum ticket <username> [OPTIONS]
[…]
# pveum rolea test -privs VM.Allocate
# pveum role d test
Options are parsed correctly:
# pveum help acl delete -v 0
USAGE: pveum acl delete <path> --roles <string> [OPTIONS]
Philip Abernethy (3):
cli: prepare CLIHandler for handling sub-commands
cli: code cleanup
cli: whitespace cleanup
src/PVE/CLIHandler.pm | 347 +++++++++++++++++++++++++++++++++-----------------
1 file changed, 228 insertions(+), 119 deletions(-)
Philip Abernethy (3):
cli: prepare CLIHandler for handling sub-commands
cli: code cleanup
cli: whitespace cleanup
src/PVE/CLIHandler.pm | 378 +++++++++++++++++++++++++++++++++-----------------
1 file changed, 252 insertions(+), 126 deletions(-)
--
2.11.0
More information about the pve-devel
mailing list