コード例 #1
0
    def test_external_with_usage(self):
        @runner.Clize.as_is(usages=['ua abc', 'ub abc [def]'])
        def ext():
            raise NotImplementedError

        def func():
            raise NotImplementedError

        sd = runner.SubcommandDispatcher([
            ext,
            runner.Clize.as_is(func, usages=['uc --ab=STR', 'ud [--cd]'])
        ])
        self._do_test(
            sd, [
                'sd --help [--usage]',
                'sd ext ua abc',
                'sd ext ub abc [def]',
                'sd func uc --ab=STR',
                'sd func ud [--cd]',
            ], """
        Usage: sd command [args...]

        Commands:
            ext
            func
        """)
コード例 #2
0
 def _test_func(self, description, footer, sigs, docs, usage, help_str):
     funcs = []
     for i, sig, doc in zip(count(1), sigs, docs):
         func = f(sig)
         func.__doc__ = doc
         func.__name__ = 'func' + str(i)
         funcs.append(func)
     sd = runner.SubcommandDispatcher(funcs, description, footer)
     self._do_test(sd, usage, help_str)
コード例 #3
0
ファイル: test_help.py プロジェクト: Rosuav/clize
    def test_dummy_external(self):
        @runner.Clize.as_is
        def ext():
            raise NotImplementedError
        def func():
            raise NotImplementedError
        sd = runner.SubcommandDispatcher([ext, runner.Clize.as_is(func)])
        self._do_test(sd, [
            'sd --help [--usage]',
            'sd ext [args...]',
            'sd func [args...]',
        ], """
        Usage: sd command [args...]

        Commands:
            ext
            func
        """)
コード例 #4
0
ファイル: test_help.py プロジェクト: Rosuav/clize
    def test_external_with_dummyhelp(self):
        @runner.Clize.as_is(description="Ext")
        def ext():
            raise NotImplementedError
        def func():
            raise NotImplementedError
        sd = runner.SubcommandDispatcher([
            ext,
            runner.Clize.as_is(func, description="Func")])
        self._do_test(sd, [
            'sd --help [--usage]',
            'sd ext [args...]',
            'sd func [args...]',
        ], """
        Usage: sd command [args...]

        Commands:
            ext     Ext
            func    Func
        """)
コード例 #5
0
ファイル: test_legacy.py プロジェクト: mgielda/clize
def run_group(functions, args):
    disp = runner.SubcommandDispatcher(functions)
    return disp.cli(*args)