def generate_usage(): usage = """ thermos commands: """ for (command, doc) in app.get_commands_and_docstrings(): usage += " " + "%-10s" % command + "\t" + doc.split("\n")[0].strip() + "\n" app.set_usage(usage)
def generate_usage(): usage = """ thermos commands: """ for (command, doc) in app.get_commands_and_docstrings(): usage += ' ' + '%-10s' % command + '\t' + doc.split('\n')[0].strip() + '\n' app.set_usage(usage)
def help_command(args, options): """Get help about a specific command. """ if len(args) == 0: app.help() for (command, doc) in app.get_commands_and_docstrings(): if args[0] == command: print('command %s:' % command) print(doc) app.quit(0) print('unknown command: %s' % args[0], file=sys.stderr)
def generate_full_usage(): docs_to_commands = collections.defaultdict(list) for (command, doc) in app.get_commands_and_docstrings(): if doc is not None: docs_to_commands[doc].append(command) def make_docstring(item): (doc_text, commands) = item def format_line(line): return ' %s\n' % line.lstrip() stripped = ''.join(map(format_line, doc_text.splitlines())) return '%s\n%s' % (make_commands_str(commands), stripped) usage = sorted(map(make_docstring, docs_to_commands.items())) return 'Available commands:\n\n' + '\n'.join(usage)
def generate_terse_usage(): """Generate minimal application usage from all registered twitter.common.app commands and return as a string.""" docs_to_commands = collections.defaultdict(list) for (command, doc) in app.get_commands_and_docstrings(): docs_to_commands[doc].append(command) usage = '\n '.join(sorted(map(make_commands_str, docs_to_commands.values()))) return """ Available commands: %s For more help on an individual command: %s help <command> """ % (usage, app.name())
def generate_full_usage(): """Generate verbose application usage from all registered twitter.common.app commands and return as a string.""" docs_to_commands = defaultdict(list) for (command, doc) in app.get_commands_and_docstrings(): docs_to_commands[doc].append(command) def make_docstring(item): (doc_text, commands) = item def format_line(line): return ' %s\n' % line.lstrip() stripped = ''.join(map(format_line, doc_text.splitlines())) return '%s\n%s' % (make_commands_str(commands), stripped) usage = sorted(map(make_docstring, docs_to_commands.items())) return 'Available commands:\n\n' + '\n'.join(usage)
def generate_terse_usage(): """Generate minimal application usage from all registered twitter.common.app commands and return as a string.""" docs_to_commands = defaultdict(list) for (command, doc) in app.get_commands_and_docstrings(): docs_to_commands[doc].append(command) usage = '\n '.join( sorted(map(make_commands_str, docs_to_commands.values()))) return """ Available commands: %s For more help on an individual command: %s help <command> """ % (usage, app.name())