Пример #1
0
# -*- coding: utf-8 -*-
"""Common functionality for parsing CLI/configuration.
"""
import os

import hac
from hac import DataType
from hac.commands import app_commands, app_commands_help


_commands_choices = sorted(app_commands.keys())
_commands_help = "\n".join(["Command to be executed:"] +
                            [app_commands_help[com]
                                for com in sorted(app_commands.keys())])


"""Constant common parse arguments used in:

    - parsers for CLI files,
    - parsers for configuration files.
"""
_pargs_pack_common_const = [
    {
        "names": ("--version",),
        "params": {
            "action": "store_true",
            "help": """show application version and exit""",
            "dest": "version",
            "default": False,
        },
    },
Пример #2
0
    """Returns CLI parse arguments.
    """
    return _pargs_pack_cli


# Parser notes.
_parser_cli_description = \
"""To execute special command that doesn't fetch remote data run: 

    hac (--help | --version | --copy-config)

To execute command that fetches remote data and processes it run:

    hac [options...] ({0}) (CONTEST | PROBLEM) [PROBLEM [PROBLEM ...]]

""".format(" | ".join(sorted(app_commands.keys())))

_parser_cli_epilog = \
"""examples: https://github.com/plesiv/hac#examples
 
"""


def get_bare_cli_parser():
    """Returns bare CLI parser object without arguments. Arguments should be
    added to parser manually.
    """
    return argparse.ArgumentParser(
        description = _parser_cli_description,
        epilog = _parser_cli_epilog,
        formatter_class=argparse.RawTextHelpFormatter