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
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
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'
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"
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()
""" 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()