Example #1
0
        def _do_it(args):
            # generate the argparse.Namespace by parsing the arguments:
            ns = parser.parse_args(args)

            # perform the associated callback:
            result = ns.callback(ns)

            # display the result:
            print('{}\n{}'.format(underline(f'{args!r}'), result))
Example #2
0
def main(args):
    setup_model()

    # create the parser from the dict (flat tree):
    parser = ParseArg(d=view, root_name='todos')

    # generate the argparse.Namespace by parsing the arguments:
    ns = parser.parse_args(args)

    # perform the associated callback:
    result = ns.callback(ns)

    # display the result:
    print('{}\n\t{}\n'.format(underline(f'{args!r}'),
                              result if result is not None else "SUCCESS"))
Example #3
0
    def do_it(node):
        def _do_it(args):
            # generate the argparse.Namespace by parsing the arguments:
            ns = parser.parse_args(args)

            # perform the associated callback:
            result = ns.callback(ns)

            # display the result:
            print('{}\n{}'.format(underline(f'{args!r}'), result))

        print(underline(f'\n\nNODE :: {node!r}'))
        with pytest.raises(SystemExit):
            _do_it(f'{node} -h')
        print('\n')

        _do_it(f'{node}')
        _do_it(f'{node} -v')
        _do_it(f'{node} -c')
        _do_it(f'{node} -v -c')
Example #4
0
def test_underline():
    s = 'hello, world!'

    assert underline(s) == 'hello, world!:\n--------------'