Exemple #1
0
    def test_print(self):
        program = Command('print', title='foobar', version='1.0.0')
        program.print_version()
        program.print_help()

        program._usage = 'print [options]'
        program.print_help()
Exemple #2
0
    def test_print(self):
        program = Command('print', title='foobar', version='1.0.0')
        program.print_version()
        program.print_help()

        program._usage = 'print [options]'
        program.print_help()
Exemple #3
0
    def test_parse(self):
        program = Command('parse', version='1.0.0')
        program.option('-f', 'force')
        program.option('-v, --verbose', 'show more log')
        program.option('--no-color', 'output without color')
        program.option('-t, --tag <tag>', 'tag name')
        program.option('-s [source]', 'source repo')
        program.option('--key <keyword>', 'keywords')

        program.print_version()
        program.print_help()

        program.parse('parse -f -v --verbose --no-color bar -t tag --key=what')

        assert program.get('-f')
        assert program.verbose
        assert program.tag == 'tag'
        assert program.color is False
        assert program.key == 'what'
Exemple #4
0
    def test_parse(self):
        program = Command('parse', version='1.0.0')
        program.option('-f', 'force')
        program.option('-v, --verbose', 'show more log')
        program.option('--no-color', 'output without color')
        program.option('-t, --tag <tag>', 'tag name')
        program.option('-s [source]', 'source repo')
        program.option('--key <keyword>', 'keywords')

        program.print_version()
        program.print_help()

        program.parse(
            'parse -f -v --verbose --no-color bar -t tag --key=what'
        )

        assert program.get('-f')
        assert program.verbose
        assert program.tag == 'tag'
        assert program.color is False
        assert program.key == 'what'
Exemple #5
0
    def test_action(self):
        program = Command('action')

        @program.action
        def lepture(bar, color=True, force=False, msg='hello'):
            """
            description of lepture subcommand.

            :param bar: description of bar
            :option bar: --bar [name]
            """
            assert bar == 'lepture'

        program.print_version()
        program.print_help()

        program.parse('action lepture --bar lepture')
        program.parse('action lepture --bar lepture baz')

        assert 'baz' in program.args

        # subcommand itself
        program.action(program)
        program.parse('action action lepture --bar lepture')
Exemple #6
0
    def test_action(self):
        program = Command('action')

        @program.action
        def lepture(bar, color=True, force=False, msg='hello'):
            """
            description of lepture subcommand.

            :param bar: description of bar
            :option bar: --bar [name]
            """
            assert bar == 'lepture'

        program.print_version()
        program.print_help()

        program.parse('action lepture --bar lepture')
        program.parse('action lepture --bar lepture baz')

        assert 'baz' in program.args

        # subcommand itself
        program.action(program)
        program.parse('action action lepture --bar lepture')