Metadata-Version: 2.1
Name: def-main
Version: 0.11.0
Summary: Define the main function in one step and make it testable
License: MIT
Author: Tom Ritchford
Author-email: tom@swirly.com
Requires-Python: >=3.7,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Description-Content-Type: text/x-rst

========================================================
``def_main``: a tiny decorator to define main
========================================================

Define the main function in one step.

For any non-trivial projects, use typer and dtyper instead!


Usage example
==================

Without an return code
~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: python

    import def_main

    @def_main
    def main(*argv):
        print('hello,', *argv)


means precisely the same as:

.. code-block:: python

    def main(*argv):
        print('hello,', *argv)


    if __name__ == '__main__':
        import sys

        main(sys.argv[1:])

With a return code
~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: python


    import def_main

    @def_main
    def main(*argv):
        print('hello,', *argv)
        return argv


means precisely the same as:

.. code-block:: python

    def main(*argv):
        print('hello,', *argv)
        return argv


    if __name__ == '__main__':
        import sys

        returncode = main(sys.argv[1:])
        sys.exit(returncode)

