Metadata-Version: 1.1
Name: subparse
Version: 0.2
Summary: A command line helper library for extensible subcommands
Home-page: https://github.com/mmerickel/subparse
Author: Michael Merickel
Author-email: me@m.merickel.org
License: MIT
Description: ========
        subparse
        ========
        
        A wrapper for argparse that provides decorator-based subcommand support.
        
        Subcommands can be defined separately from their actual main functions,
        enabling faster import times.
        
        Basic Usage
        ===========
        
        ::
        
            from subparse import CLI
        
            cli = CLI(version='0.0')
            cli.add_generic_option('--quiet', action='store_true',
                                   help='turn of debugging')
        
            @cli.subcommand(__name__ + ':foo_main')
            def foo(parser):
                """
                a short description ending in a period.
        
                a longer description
                """
                parser.add_argument('--bar', action='store_true',
                                    help='turn on bar')
        
            def foo_main(app, args):
                pass
        
            args = cli.parse()
            app = MyApp(args)
            cli.dispatch(args, context=app)
        
        Lazy Decorators
        ===============
        
        Subcommands can be defined lazily and picked up later. This removes ordering
        restrictions between the subcommands and the cli object.
        
        ::
        
            # myapp/info.py
        
            from subparse import subcommand
        
            @subcommand('myapp.info:foo_main')
            def foo(parser):
                """perform foo"""
        
        ::
        
            import myapp.info
        
            cli = CLI()
            cli.load_commands(myapp.info)
        
        Entry Points
        ============
        
        Subcommands may also be defined in external modules and loaded via entry
        points.
        
        ::
        
            from subparse import cli
        
            cli = CLI()
            cli.load_commands_from_entry_point('myapp.subcommands')
        
        An extension application would then define the external module that should
        be searched for subcommands. Again this allows the commands themselves
        to be defined independently of the main functions, improving import speed.
        
        ::
        
            [myapp.subcommands]
            barpkg = barpkg.subcommands
        
        ::
        
            # barpkg/subcommands.py
        
            from subparse import subcommand
        
            @subcommand('barpkg.bar')
            def bar(parser):
                """perform bar"""
        
        ::
        
            # barpkg/bar.py
        
            def main(app, args):
                pass
        
        
        
        0.2 (2013-08-06)
        ================
        
        - Underscores in function names are converted to dashes in their respective
          subcommand names.
        - Add `CLI.add_generic_options` API.
        - Add a new `help` subcommand, allowing for `myapp help foo`.
        - Allow relative imports in the subcommand specification.
        
        0.1 (2013-08-05)
        ================
        
        - Initial Commits
        
Keywords: argparse cli commandline subcommand
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Environment :: Console
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
