Exemple #1
0
    def test_loading_logging(self):
        import logging
        target = CliApplication(
            tests.sample_app,
            application_settings='tests.sample_app.logging_settings')

        target.dispatch(args=('--log-level', 'WARN', 'settings'))
        assert logging.root.level == logging.WARN
Exemple #2
0
    def test_loading_logging(self):
        import logging

        target = CliApplication(
            tests.sample_app,
            application_settings="tests.sample_app.logging_settings")

        target.dispatch(args=("--log-level", "WARN", "settings"))
        assert logging.root.level == logging.WARN
Exemple #3
0
    def test_dispatch_args(self):
        closure = {}

        target = CliApplication(tests.sample_app)

        @target.register_handler(cli_name='sample')
        @add_argument('--foo', dest='foo')
        def sample_handler(opts):
            closure['opts'] = opts

        target.dispatch(args=('sample', '--foo', 'bar'))

        assert closure['opts'].foo == 'bar'
Exemple #4
0
    def test_dispatch_args(self):
        closure = {}

        target = CliApplication(tests.sample_app)

        @target.command(name="sample")
        @argument("--foo", dest="foo")
        def sample_handler(opts):
            closure["opts"] = opts

        target.dispatch(args=("sample", "--foo", "bar"))

        assert closure["opts"].foo == "bar"
Exemple #5
0
from pyapp.app import CliApplication, argument

import sample

app = CliApplication(sample,
                     name="PyApp Sample",
                     description="Sample pyApp application.")


@app.command
def foo(opts):
    print("bar")


if __name__ == "__main__":
    app.dispatch()
Exemple #6
0
"""
Single file sample
"""
from pyapp.app import argument
from pyapp.app import CliApplication
from pyapp.app import CommandOptions
from pyapp.app import KeyValueAction

APP = CliApplication()


@APP.default
def helper(*, bar: dict):
    print(bar)
    # print(opts.bar)


if __name__ == "__main__":
    APP.dispatch()