9
9
from compiler_admin .commands .user .convert import ACCOUNT_TYPE_OU
10
10
11
11
12
+ def add_sub_cmd_parser (parser : ArgumentParser , dest = "subcommand" , help = None ):
13
+ """Helper adds a subparser for the given dest."""
14
+ return parser .add_subparsers (dest = dest , help = help )
15
+
16
+
12
17
def add_sub_cmd (cmd : _SubParsersAction , subcmd , help ) -> ArgumentParser :
13
18
"""Helper creates a new subcommand parser."""
14
19
return cmd .add_parser (subcmd , help = help )
@@ -36,7 +41,7 @@ def main(argv=None):
36
41
version = f"%(prog)s { version } " ,
37
42
)
38
43
39
- cmd_parsers = parser . add_subparsers ( dest = "command" , help = "The command to run" )
44
+ cmd_parsers = add_sub_cmd_parser ( parser , dest = "command" , help = "The command to run" )
40
45
41
46
info_cmd = add_sub_cmd (cmd_parsers , "info" , help = "Print configuration and debugging information." )
42
47
info_cmd .set_defaults (func = info )
@@ -50,7 +55,7 @@ def main(argv=None):
50
55
51
56
time_cmd = add_sub_cmd (cmd_parsers , "time" , help = "Work with Compiler time entries" )
52
57
time_cmd .set_defaults (func = time )
53
- time_subcmds = time_cmd . add_subparsers ( "subcommand" , help = "The time command to run." )
58
+ time_subcmds = add_sub_cmd_parser ( time_cmd , help = "The time command to run." )
54
59
55
60
time_convert = add_sub_cmd (time_subcmds , "convert" , help = "Convert a time report from one format into another." )
56
61
time_convert .add_argument (
@@ -63,7 +68,7 @@ def main(argv=None):
63
68
64
69
user_cmd = add_sub_cmd (cmd_parsers , "user" , help = "Work with users in the Compiler org." )
65
70
user_cmd .set_defaults (func = user )
66
- user_subcmds = user_cmd . add_subparsers ( dest = "subcommand" , help = "The user command to run." )
71
+ user_subcmds = add_sub_cmd_parser ( user_cmd , help = "The user command to run." )
67
72
68
73
user_create = add_sub_cmd_username (user_subcmds , "create" , help = "Create a new user in the Compiler domain." )
69
74
user_create .add_argument ("--notify" , help = "An email address to send the newly created account info." )
0 commit comments