in azdev/operations/command_change/custom.py [0:0]
def gen_command_meta(command_info, with_help=False, with_example=False):
stored_property_when_exist = ["confirmation", "supports_no_wait", "is_preview", "deprecate_info"]
command_meta = {
"name": command_info["name"],
"is_aaz": command_info["is_aaz"],
}
for prop in stored_property_when_exist:
if command_info.get(prop, None):
command_meta[prop] = command_info[prop]
if with_example:
get_command_examples(command_info, command_meta)
if with_help:
if command_info.get("help", None) and hasattr(command_info["help"], "short_summary"):
command_meta["desc"] = command_info["help"].short_summary
parameters = []
for _, argument in command_info["arguments"].items():
if argument.type is None:
continue
settings = argument.type.settings
if settings.get("action", None):
action = settings["action"]
if hasattr(action, "__name__") and action.__name__ == "IgnoreAction":
# ignore argument like: cmd
continue
para = {
"name": settings["dest"],
}
process_arg_deprecation(settings, para)
process_arg_options(settings, para)
process_arg_options_deprecation(settings, para)
process_arg_type(settings, para)
if settings.get("required", False):
para["required"] = True
if settings.get("choices", None):
para["choices"] = sorted(list(settings["choices"]))
if settings.get("id_part", None):
para["id_part"] = settings["id_part"]
if settings.get("nargs", None):
para["nargs"] = settings["nargs"]
if settings.get("completer", None):
para["has_completer"] = True
if settings.get("default", None):
if not isinstance(settings["default"], (float, int, str, list, bool)):
para["default"] = str(settings["default"])
else:
para["default"] = settings["default"]
if with_help:
para["desc"] = settings.get("help", "")
if command_info["is_aaz"] and command_info["az_arguments_schema"]:
process_aaz_argument(command_info["az_arguments_schema"], settings, para)
normalize_para_types(para)
parameters.append(para)
command_meta["parameters"] = parameters
return command_meta