@@ -119,6 +119,15 @@ def normalize_para_type(type_opts, value):
119119 normalize_para_type (type_bool_opts , "bool" )
120120
121121
122+ def get_command_examples (command_info , command_meta ):
123+ example_items = []
124+ if command_info and command_info .get ("help" , None ) and hasattr (command_info ["help" ], "examples" ):
125+ for example_obj in command_info ["help" ].examples :
126+ example_items .append ({"name" : example_obj .name , "text" : example_obj .text })
127+ if example_items :
128+ command_meta ["examples" ] = example_items
129+
130+
122131def gen_command_meta (command_info , with_help = False , with_example = False ):
123132 stored_property_when_exist = ["confirmation" , "supports_no_wait" , "is_preview" , "deprecate_info" ]
124133 command_meta = {
@@ -129,15 +138,10 @@ def gen_command_meta(command_info, with_help=False, with_example=False):
129138 if command_info .get (prop , None ):
130139 command_meta [prop ] = command_info [prop ]
131140 if with_example :
132- try :
133- command_meta ["examples" ] = command_info ["help" ]["examples" ]
134- except AttributeError :
135- pass
141+ get_command_examples (command_info , command_meta )
136142 if with_help :
137- try :
138- command_meta ["desc" ] = command_info ["help" ]["short-summary" ]
139- except AttributeError :
140- pass
143+ if command_info .get ("help" , None ) and hasattr (command_info ["help" ], "short_summary" ):
144+ command_meta ["desc" ] = command_info ["help" ].short_summary
141145 parameters = []
142146 for _ , argument in command_info ["arguments" ].items ():
143147 if argument .type is None :
@@ -163,13 +167,15 @@ def gen_command_meta(command_info, with_help=False, with_example=False):
163167 para ["id_part" ] = settings ["id_part" ]
164168 if settings .get ("nargs" , None ):
165169 para ["nargs" ] = settings ["nargs" ]
170+ if settings .get ("completer" , None ):
171+ para ["has_completer" ] = True
166172 if settings .get ("default" , None ):
167173 if not isinstance (settings ["default" ], (float , int , str , list , bool )):
168174 para ["default" ] = str (settings ["default" ])
169175 else :
170176 para ["default" ] = settings ["default" ]
171177 if with_help :
172- para ["desc" ] = settings [ "help" ]
178+ para ["desc" ] = settings . get ( "help" , "" )
173179 if command_info ["is_aaz" ] and command_info ["az_arguments_schema" ]:
174180 process_aaz_argument (command_info ["az_arguments_schema" ], settings , para )
175181 normalize_para_types (para )
0 commit comments