def output_help_cli(commands, groups): """ Prints a summary of all commands. """ max_len = max((len(c) for c in commands)) + 1 fmt = ' %-{}s'.format(max_len) for group_name, comm_names in groups.items(): cli_out_write(group_name, Color.BRIGHT_MAGENTA) for name in comm_names: # future-proof way to ensure tabular formatting cli_out_write(fmt % name, Color.GREEN) # Help will be all the lines up to the first empty one docstring_lines = commands[name].doc.split('\n') start = False data = [] for line in docstring_lines: line = line.strip() if not line: if start: break start = True continue data.append(line) txt = textwrap.fill(' '.join(data), 80, subsequent_indent=" " * (max_len + 2)) cli_out_write(txt) cli_out_write("") cli_out_write('Conan commands. Type "conan <command> -h" for help', Color.BRIGHT_YELLOW)
def output_remote_list_cli(info): for remote_info in info: output_str = "{}: {} [SSL: {}, Enabled: {}]".format(remote_info["name"], remote_info["url"], remote_info["ssl"], remote_info["enabled"]) cli_out_write(output_str)
def output_search_cli(info): for remote_info in info: source = "cache" if remote_info["remote"] is None else str( remote_info["remote"]) cli_out_write("{}:".format(source), Color.BRIGHT_WHITE) for conan_item in remote_info["items"]: reference = conan_item["recipe"]["id"] cli_out_write(" {}".format(reference))
def output_search_json(info): myjson = json.dumps(info, indent=4) cli_out_write(myjson)
def output_user_list_json(info): myjson = json.dumps(info, indent=4) cli_out_write(myjson)
def output_user_list_cli(info): for remote_name, user_info in info.items(): output_str = "remote: {} user: {}".format(remote_name, user_info["user"]) cli_out_write(output_str)