@@ -26,29 +26,6 @@ def __init__(self, shell_ctx):
2626 self .command_table = None
2727 self .shell_ctx = shell_ctx
2828
29- def install_modules (self ):
30- installed_command_modules = []
31- for cmd in self .command_table :
32- try :
33- self .command_table [cmd ].load_arguments ()
34- except (ImportError , ValueError ):
35- pass
36- mods_ns_pkg = import_module ('azure.cli.command_modules' )
37- for _ , modname , _ in pkgutil .iter_modules (mods_ns_pkg .__path__ ):
38- if modname not in BLACKLISTED_MODS :
39- installed_command_modules .append (modname )
40-
41- for mod in installed_command_modules :
42- try :
43- mod = import_module ('azure.cli.command_modules.' + mod )
44- mod .load_params (mod )
45- mod .load_commands ()
46-
47- except Exception : # pylint: disable=broad-except
48- # print("Error loading: {}".format(mod))
49- pass
50- self .shell_ctx .cli_ctx .invocation .commands_loader .load_arguments (None )
51-
5229 def load_help_files (self , data ):
5330 """ loads all the extra information from help files """
5431 for cmd in helps :
@@ -95,38 +72,36 @@ def load_help_files(self, data):
9572 def dump_command_table (self , shell_ctx ):
9673 """ dumps the command table """
9774
98- self .command_table = shell_ctx .cli_ctx .invocation .commands_loader .command_table
99- command_file = shell_ctx .config .get_help_files ()
100-
101- self .install_modules ()
102- add_id_parameters (self .command_table )
75+ loader = shell_ctx .cli_ctx .invocation .commands_loader
76+ cmd_table = loader .load_command_table (None )
77+ loader .load_arguments ('' )
10378
10479 data = {}
105- for cmd in self . command_table :
80+ for cmd in cmd_table :
10681 com_descrip = {} # commands to their descriptions, examples, and parameter info
10782 param_descrip = {} # parameters to their aliases, required, and descriptions
10883
10984 try :
110- command_description = self . command_table [cmd ].description
85+ command_description = cmd_table [cmd ].description
11186 if callable (command_description ):
11287 command_description = command_description ()
11388
11489 com_descrip ['help' ] = command_description
11590 com_descrip ['examples' ] = ""
11691
11792 # checking all the parameters for a single command
118- for key in self . command_table [cmd ].arguments :
93+ for key in cmd_table [cmd ].arguments :
11994 required = ""
12095 help_desc = ""
12196
122- if self . command_table [cmd ].arguments [key ].type .settings .get ('required' ):
97+ if cmd_table [cmd ].arguments [key ].type .settings .get ('required' ):
12398 required = "[REQUIRED]"
124- if self . command_table [cmd ].arguments [key ].type .settings .get ('help' ):
125- help_desc = self . command_table [cmd ].arguments [key ].type .settings .get ('help' )
99+ if cmd_table [cmd ].arguments [key ].type .settings .get ('help' ):
100+ help_desc = cmd_table [cmd ].arguments [key ].type .settings .get ('help' )
126101
127102 # checking aliasing
128103 name_options = []
129- for name in self . command_table [cmd ].arguments [key ].options_list :
104+ for name in cmd_table [cmd ].arguments [key ].options_list :
130105 name_options .append (name )
131106
132107 options = {
@@ -135,16 +110,20 @@ def dump_command_table(self, shell_ctx):
135110 'help' : help_desc
136111 }
137112 # the key is the first alias option
138- param_descrip [self . command_table [cmd ].arguments [key ].options_list [0 ]] = options
113+ param_descrip [cmd_table [cmd ].arguments [key ].options_list [0 ]] = options
139114
140115 com_descrip ['parameters' ] = param_descrip
141116 data [cmd ] = com_descrip
142117 except (ImportError , ValueError ):
143118 pass
144119
120+ add_id_parameters (cmd_table )
145121 self .load_help_files (data )
146122
123+ self .command_table = cmd_table
124+
147125 # dump into the cache file
126+ command_file = shell_ctx .config .get_help_files ()
148127 with open (os .path .join (get_cache_dir (shell_ctx ), command_file ), 'w' ) as help_file :
149128 json .dump (data , help_file )
150129
0 commit comments