Metadata-Version: 2.0
Name: defopt
Version: 0.2.0
Summary: Effortless argument parsing
Home-page: https://pypi.python.org/pypi/defopt
Author: evan_
Author-email: evanunderscore@gmail.com
License: GNU General Public License v3
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Requires-Dist: docutils
Requires-Dist: enum34; python_version=="3.3"

======
defopt
======

defopt allows you to effortlessly call Python functions from the command line.

defopt will:

- Allow functions to be called identically from code or the command line
- Reward you for documenting your functions
- Produce informative command line help messages
- Save you from writing and maintaining argument parsing code ever again

defopt will not:

- Modify your functions in any way
- Allow you to build complex command line tools (try docopt_ or click_)

Usage
-----

Once you have written and documented your main function (currently you must use
Sphinx-style_ docstrings), simply decorate it with ``@defopt.main``, then call
``defopt.run()`` to see the magic happen.

::

    import defopt

    @defopt.main
    def main(greeting, count=1):
        """Display a friendly greeting.

        :param str greeting: Greeting to display
        :param int count: Number of times to display the greeting
        """
        for _ in range(count):
            print(greeting)

    if __name__ == '__main__':
        defopt.run()

This function can now be called identically from Python and the command line.

::

    >>> from test import main
    >>> main('hello!', count=2)
    hello!
    hello!

::

    $ python test.py hello! --count 2
    hello!
    hello!

Development
-----------

For source code, examples, questions, feature requests and bug reports, visit
the `GitHub repository`_.

.. _Sphinx-style: http://www.sphinx-doc.org/en/stable/domains.html#info-field-lists
.. _docopt: http://docopt.org/
.. _click: http://click.pocoo.org/
.. _GitHub repository: https://github.com/evanunderscore/defopt


