Ejemplo n.º 1
0
 def __call__(self, *a, **kw):
     actions = [
         Action([i], help=getattr(pathmaker, i).__doc__, dest='')
         for i in sorted(pathmaker.__all__)
         if not i.startswith('_') and callable(getattr(pathmaker, i))
     ]
     formatter = HelpFormatter('')
     formatter.add_text(
         "An explicit layout strategy can be specified.  This is to "
         "instruct how ExplosiveFUSE should present file entries across "
         "all archive files within its mount point.  Do note that "
         "the final outcome of the layout is also influenced by the usage "
         "of the '--overwrite' and the '--omit-arcname' flags, and "
         "arguments which may associate with each of the strategies. "
         "They are specified by appending ':', followed by the value of "
         "each positional argument(s).")
     formatter.start_section('Available layout strategies')
     formatter.add_arguments(actions)
     formatter.end_section()
     print(formatter.format_help())
     sys.exit(0)
Ejemplo n.º 2
0
 def __call__(self, *a, **kw):
     actions = [
         Action([i], help=getattr(pathmaker, i).__doc__, dest='')
         for i in sorted(pathmaker.__all__)
         if not i.startswith('_') and callable(getattr(pathmaker, i))
     ]
     formatter = HelpFormatter('')
     formatter.add_text(
         "An explicit layout strategy can be specified.  This is to "
         "instruct how ExplosiveFUSE should present file entries across "
         "all archive files within its mount point.  Do note that "
         "the final outcome of the layout is also influenced by the usage "
         "of the '--overwrite' and the '--omit-arcname' flags, and "
         "arguments which may associate with each of the strategies. "
         "They are specified by appending ':', followed by the value of "
         "each positional argument(s)."
     )
     formatter.start_section('Available layout strategies')
     formatter.add_arguments(actions)
     formatter.end_section()
     print(formatter.format_help())
     sys.exit(0)
Ejemplo n.º 3
0
def get_help(parser):
    """
    Return help text for the parser.

    :param parser: parser
    :type parser: ArgumentParser
    :return: fully formatted help string
    :rtype: str
    """
    # Code almost identical with parser.print_help() with next changes:
    # it return text instead print
    # it place group 'command arguments' to the first place
    width = min(get_terminal_width(), 100)
    formatter = HelpFormatter(prog=parser.prog,
                              max_help_position=30,
                              width=width)
    # usage
    formatter.add_usage(parser.usage, parser._actions,
                        parser._mutually_exclusive_groups)
    # description
    formatter.add_text(parser.description)

    # positionals, optionals and user-defined groups
    groups = list(parser._action_groups)
    groups.sort(key=lambda x: x.title != 'command arguments')
    for action_group in groups:
        formatter.start_section(action_group.title)
        formatter.add_text(action_group.description)
        formatter.add_arguments(action_group._group_actions)
        formatter.end_section()

    # epilog
    formatter.add_text(parser.epilog)

    # determine help from format above
    return formatter.format_help()