Пример #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()
Пример #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()
Пример #3
0
    def test_subcommand(self):
        program = Command('subcommand')

        @program.subcommand
        def bar():
            return 'bar'

        program.print_help()
Пример #4
0
 def test_help_footer(self):
     footers = [
         'Examples:',
         '',
         '  $ terminal -h'
     ]
     program = Command('footer', help_footer='\n'.join(footers))
     program.print_help()
Пример #5
0
    def test_subcommand(self):
        program = Command('subcommand')

        @program.subcommand
        def bar():
            return 'bar'

        program.print_help()
Пример #6
0
    def test_call(self):
        # for __call__
        program = Command('call')

        @program
        def bar():
            return 'bar'

        program.print_help()
Пример #7
0
    def test_call(self):
        # for __call__
        program = Command('call')

        @program
        def bar():
            return 'bar'

        program.print_help()
Пример #8
0
    def test_add_action(self):
        program = Command('add-action')

        @program.action
        def hello(bar):
            """
            description of hello

            usage: hello <bar>
            """
            assert bar == 'baz'

        program.parse('add-action hello baz')
        program.print_help()
Пример #9
0
    def test_add_action(self):
        program = Command('add-action')

        @program.action
        def hello(bar):
            """
            description of hello

            usage: hello <bar>
            """
            assert bar == 'baz'

        program.parse('add-action hello baz')
        program.print_help()
Пример #10
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'
Пример #11
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'
Пример #12
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')
Пример #13
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')
Пример #14
0
 def test_arguments(self):
     program = Command('arguments', arguments=['name', 'hello'])
     program.print_help()
     program.parse('arguments foo')
     assert program.name == 'foo'
Пример #15
0
 def test_arguments(self):
     program = Command('arguments', arguments=['name', 'hello'])
     program.print_help()
     program.parse('arguments foo')
     assert program.name == 'foo'
Пример #16
0
 def test_help_footer(self):
     footers = ['Examples:', '', '  $ terminal -h']
     program = Command('footer', help_footer='\n'.join(footers))
     program.print_help()