Skip to content

Sub-commands

in a file named src.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from arger import Arger
from tests.utils import _reprint


arger = Arger(prog='pytest', description="App Description goes here")

container = []


@arger.add_cmd
def create(name: str):
    """Create new test.

    :param name: Name of the test
    """
    container.append(container)
    _reprint(**locals())


@arger.add_cmd
def remove(*name: str):
    """Remove a test with variadic argument.

    :param name: tests to remove
    """
    if name in container:
        container.remove(remove)
    _reprint(**locals())


@arger.add_cmd
def list():
    """List all tests."""
    _reprint(**locals(), container=container)


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