#!/usr/bin/env python from dataclasses import dataclass, field import sys, re, os, enum, itertools from functools import partial, partialmethod from time import sleep from subprocess import Popen, PIPE, DEVNULL from operator import itemgetter from defl import log, cl, Path, Undefined, Null, Assert, Time, Obj, Dunder, IterableType, isIterableType, Run, checkType from defl import CLIError from defl._typing_ import * import defl @dataclass(slots=T, kw_only=T, frozen=F) class CLI(): kill: bool = False paths: list = None def __post_init__(_): _.paths = [] if _.paths is None else _.paths @defl.patchClass(CLI) def main(_, *com): assert com paths = _.paths if not paths: for i in com: if Path(i).exists(): paths.append(i) paths = [Path(x) for x in paths] kill = ['-k'] if _.kill else [] if (p := Path("~/deflDev/defl/")).exists(): paths.append(p) if (p := Path("~/defl/defl/")).exists(): paths.append(p) paths = [('-p', x) for x in paths] paths = list(itertools.chain(*paths)) cmd = [defl.which('onFileChange.py'), '-', *kill, *paths, '--', *com] Run(cmd).run(F, F).assSuc() if __name__ == '__main__': defl.cliAutoParse(CLI, mapSubParsers={'-': 'main'})