Beispiel #1
0
from arger import Arger
from argparse import Namespace
from tests.utils import _reprint


def main(param1: int,
         param2: str,
         _namespace_: Namespace,
         kw1=None,
         kw2=False):
    """Example function with types documented in the docstring.

    :param param1: The first parameter.
    :param param2: The second parameter.
    :param kw1: this is optional parameter.
    :param kw2: this is boolean. setting flag sets True.
    """
    _reprint(**locals())


arger = Arger(
    main,
    prog='pytest',  # for testing purpose. otherwise not required
)

if __name__ == '__main__':
    arger.run()
Beispiel #2
0
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():
Beispiel #3
0
def main():
    Arger(_main, formatter_class=ap.RawTextHelpFormatter).run()
Beispiel #4
0
 def _add(argument):
     par = Arger()
     argument.add_to(par)
     return par
Beispiel #5
0
import shlex
import subprocess as sp
import sys

from typing_extensions import Literal

from arger import Arger

arger = Arger(description="Common set of tasks to run", )


class Color:
    HEADER = "\033[95m"
    OKBLUE = "\033[94m"
    OKGREEN = "\033[92m"
    WARNING = "\033[93m"
    FAIL = "\033[91m"
    BOLD = "\033[1m"
    UNDERLINE = "\033[4m"

    # reset
    RESET = "\033[0m"


def prun(*cmd, **kwargs):
    if len(cmd) == 1 and len(shlex.split(cmd[0])) > 1:
        cmd = shlex.split(cmd[0])
    print(f"{Color.OKGREEN} $ {' '.join(cmd)}{Color.RESET}")
    c = sp.run(cmd, **kwargs, capture_output=True)
    sys.stdout.write(c.stdout.decode())
    sys.stdout.flush()