Metadata-Version: 2.4
Name: def-main
Version: 0.12.0
Summary: 🗣 A decorator for main 🗣
Author-email: Tom Ritchford <tom@swirly.com>
License-Expression: MIT
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Requires-Dist: xmod<2,>=1.3.2
Description-Content-Type: text/markdown

# `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

``` python
import def_main

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

means precisely the same as:

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


if __name__ == '__main__':
    import sys

    main(sys.argv[1:])
```

### With a return code

``` python
import def_main

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

means precisely the same as:

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


if __name__ == '__main__':
    import sys

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