~brenns10/subc

abf9c7dd3de939740d36aa6f4c33320d56ddabad — Stephen Brennan 2 years ago f343a1a v0.2.0
Update readme for 0.2.0
1 files changed, 33 insertions(+), 7 deletions(-)

M README.rst
M README.rst => README.rst +33 -7
@@ 12,8 12,7 @@ Installation
Use
---

Create your own command subclass for your application (optional, but
encouraged):
Create your own command subclass for your application:


.. code:: python


@@ 36,11 35,38 @@ and running your application:

.. code:: python

    def main():
        parser = argparse.ArgumentParser(description='a cool tool')
        MyCmd.add_commands(parser)
        args = parser.parse_args()
        args.func(args)
    if __name__ == '__main__':
        MyCmd.main()

Advanced Use
------------

You may find yourself wanting to create intermediate subclasses for your
application, in order to share common functionality. For example, you might
create a class for all commands which handle a single file as an argument:

.. code:: python

    class FileCmd(MyCmd):
        def add_args(self, parser):
            parser.add_args('file', help='the single file')

You can do that, so long as your intermediate subclasses are not executable. For
example, given the following class hierarchy:

.. code::

    MyCmd*
    |- FileCmd*
    |  |- AppendLineCmd
    |  |- RemoveLineCmd
    |- DoSomethingElseCmd

The non-leaf commands (marked with an asterisk) will not be included as
executable commands. Only leaf classes will be executable.

``subc`` is a very simple library. If you have other advanced uses, read the
code.

License
-------