Exemplo n.º 1
0
def test_adding_commands():
    p = Parguments(__doc__)
    assert p._commands == {}

    @p.command
    def add(name):
        """
        Usage:
            parguments add <name>
        """
        assert name == "catsup"

    assert "add" in p._commands

    def remove(name):
        """
        Usage:
            parguments remove <name>
        """
        assert name == "wordpress"

    p.add_command(remove)
    assert "remove" in p._commands

    p.run(argv=["add", "catsup"], exit=False)
    p.run(command="add", argv=["remove", "catsup"], exit=False)

    import sys

    sys.argv[1:] = ["add", "catsup"]

    p.run(exit=False)

    try:
        p.run(argv=["remove", "wordpress"])
    except SystemExit:
        pass
    else:
        raise
Exemplo n.º 2
0
        -s --settings=<file>    specify a setting file. [default: config.json]
    """
    pass

@parguments.command
def build(settings):
    """
    Usage:
        catsup build [-s <file>|--settings=<file>]

    Options:
        -h --help               show this screen.
        -s --settings=<file>    specify a setting file. [default: config.json]
    """
    pass

@parguments.command
def deploy(settings):
    """
    Usage:
        catsup deploy [-s <file>|--settings=<file>]

    Options:
        -h --help               show this screen.
        -s --settings=<file>    specify a setting file. [default: config.json]
    """
    pass

if __name__ == '__main__':
    parguments.run()
Exemplo n.º 3
0
def test_help():
    p = Parguments(__doc__)

    assert p.run(argv=["-h"], exit=False) == 0
    assert p.run(argv=["--help"], exit=False) == 0
Exemplo n.º 4
0
                          receive pack program
    -u, --set-upstream    set upstream for git pull/status
    --progress            force progress reporting

""")

git.add_command(name='remote', func=print_args,
    doc="""
usage: git remote [-v | --verbose]
       git remote add [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>
       git remote rename <old> <new>
       git remote rm <name>
       git remote set-head <name> (-a | -d | <branch>)
       git remote [-v | --verbose] show [-n] <name>
       git remote prune [-n | --dry-run] <name>
       git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]
       git remote set-branches <name> [--add] <branch>...
       git remote set-url <name> <newurl> [<oldurl>]
       git remote set-url --add <name> <newurl>
       git remote set-url --delete <name> <url>

    -v, --verbose         be verbose; must be placed before a subcommand
""")


def fallback(cmd, args):
    print("%s is not a git.py command. See 'git help'." % cmd)

if __name__ == '__main__':
    git.run('<command>', default_command='help', fallback=fallback)