From 0f2d1f1dba4a91ef7c0c7104e1995ae8d2cba576 Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Mon, 27 Sep 2021 12:44:46 +0200 Subject: Show all valid commands when running ogcli --help Commands are retrieved using dir() so future commands will show accordingly. "ogcli --help" now will print: usage: ogcli [-h] {create,list,rest,restore,send,set,setup} positional arguments: {create,list,rest,restore,send,set,setup} Subcommand to run optional arguments: -h, --help show this help message and exit --- ogcli | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ogcli b/ogcli index fd6eade..abea632 100755 --- a/ogcli +++ b/ogcli @@ -34,7 +34,9 @@ class CLI(): self.ogcli = OgCLI(self.cfg) parser = argparse.ArgumentParser(prog='ogcli') - parser.add_argument('command', help='Subcommand to run') + parser.add_argument('command', help='Subcommand to run', + choices=[attr for attr in dir(self.ogcli) + if not str.startswith(attr, "_")]) args = parser.parse_args(sys.argv[1:2]) if not hasattr(self.ogcli, args.command): -- cgit v1.2.3-18-g5258