13
13
from awsshell import determine_index_filename
14
14
15
15
16
- # arguments/commands are used for completions
17
- # children is used for further indexing of subcommands.
18
- INDEX = { 'aws' : { 'arguments' : [], 'commands' : [], 'children' : {} }}
16
+ def new_index ():
17
+ return { 'arguments' : [], 'required_arguments' : [],
18
+ 'commands' : [], 'children' : {}}
19
19
20
20
21
21
def index_command (index_dict , help_command ):
22
- for arg in help_command .arg_table :
22
+ arg_table = help_command .arg_table
23
+ for arg in arg_table :
24
+ if arg_table [arg ].required :
25
+ index_dict ['required_arguments' ].append ('--%s' % arg )
23
26
index_dict ['arguments' ].append ('--%s' % arg )
24
27
for cmd in help_command .command_table :
25
28
index_dict ['commands' ].append (cmd )
26
29
# Each sub command will trigger a recurse.
27
- child = { 'arguments' : [], 'commands' : [], 'children' : {}}
30
+ child = new_index ()
28
31
index_dict ['children' ][cmd ] = child
29
32
sub_command = help_command .command_table [cmd ]
30
33
sub_help_command = sub_command .create_help_command ()
@@ -40,10 +43,11 @@ def main():
40
43
args .output = determine_index_filename ()
41
44
driver = awscli .clidriver .create_clidriver ()
42
45
help_command = driver .create_help_command ()
43
- current = INDEX ['aws' ]
46
+ index = {'aws' : new_index ()}
47
+ current = index ['aws' ]
44
48
index_command (current , help_command )
45
49
46
- result = pprint .pformat (INDEX )
50
+ result = pprint .pformat (index )
47
51
if not os .path .isdir (os .path .dirname (args .output )):
48
52
os .makedirs (os .path .dirname (args .output ))
49
53
with open (args .output , 'w' ) as f :
0 commit comments