64 lines
1.5 KiB
Python
Executable File
64 lines
1.5 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import enum
|
|
import itertools
|
|
import json
|
|
import os
|
|
import re
|
|
import sys
|
|
from dataclasses import KW_ONLY, dataclass, field
|
|
from functools import partial, partialmethod
|
|
from operator import itemgetter
|
|
from tabnanny import verbose
|
|
from time import sleep
|
|
from traceback import print_list
|
|
|
|
import defl
|
|
from defl import CLIError, DotDict, Null, Path, Undefined, cl, log
|
|
from defl._assert_ import Assert
|
|
from defl._typing_ import *
|
|
from defl.testing_ import Tester
|
|
from defl.cliWrapper_ import *
|
|
|
|
tester = Tester(name=__file__)
|
|
|
|
|
|
@dataclass(slots=T, kw_only=T, frozen=T)
|
|
class Opt(CliOptions):
|
|
_OptionsMap = {'a': '--aaa', 'b': '-b', 'c': '-c', 'd': '-d', 'e': '-e', 'f': '-f'}
|
|
a: str | N = N
|
|
b: str | N = N
|
|
c: str | N = N
|
|
d: str | N = N
|
|
e: str | N = N
|
|
f: str | N = N
|
|
listt: list[str] | N = N
|
|
|
|
|
|
@tester.add()
|
|
def join():
|
|
a = Opt(a='a')
|
|
b = Opt(b='b')
|
|
c = Opt(c='c')
|
|
d = Opt(d='d')
|
|
e = Opt(e='e')
|
|
f = Opt(f='f')
|
|
la = Opt(listt=['la'])
|
|
lb = Opt(listt=['lb'])
|
|
Assert(a | b | c | d | e | f) == Opt(a='a', b='b', c='c', d='d', e='e', f='f')
|
|
Assert(la | lb) == Opt(listt=['la', 'lb'])
|
|
Assert(la | lb | la) == Opt(listt=['la', 'lb', 'la'])
|
|
|
|
|
|
@tester.add()
|
|
def cli():
|
|
Assert((a | b | c | d | e | f).cli) == ['--aaa=a', '-b=b', '-c=c', '-d=d', '-e=e', '-f=f']
|
|
Assert((la | lb | la).cli) == ['--listt=la', '--listt=lb', '--listt=la']
|
|
|
|
|
|
log.info(tester.run())
|
|
tester.exitWithStatus()
|
|
|
|
# for i in ch:
|
|
# print(defl.printTable([[y for y in x] for x in ch], squareFill=True))
|