Description

Very basic script demonstrating the demonstration feature, adding an option to start a demo using one of the available examples defined in __examples__.

No example provided

If __examples__ is not defined or is en empty list, the --demo will simply not be available, even if add_demo is True in the initialize function.

Code

1
2
3
4
5
6
7
8
from tinyscript import *

__examples__ = ["", "--test"]

if __name__ == '__main__':
    parser.add_argument("--test", action="store_true", help="test argument")
    initialize(add_demo=True)
    logger.success("First example" if not args.test else "Second example")

Help

1
2
$ python demo.py -h
usage: python demo.py [--test] [--demo] [-h] [--help] [-v]

Execution

1
2
$ python demo.py --demo
12:34:56 [SUCCESS] First example
1
2
$ python demo.py --demo
12:34:56 [SUCCESS] Second example