[pve-devel] [PATCH common v6 0/3] CLI: Sub-commands and aliases
Philip Abernethy
p.abernethy at proxmox.com
Tue Oct 17 13:16:24 CEST 2017
Patches reordered for v6 as per Thomas' suggestion.
This patch (3/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]
_______________________________________________
pve-devel mailing list
pve-devel at pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Philip Abernethy (3):
cli: code cleanup
cli: whitespace cleanup
cli: prepare CLIHandler for handling sub-commands
src/PVE/CLIHandler.pm | 379 +++++++++++++++++++++++++++++++++-----------------
1 file changed, 253 insertions(+), 126 deletions(-)
--
2.11.0
More information about the pve-devel
mailing list