Coverage for aikasilta/cli.py: 82.61%

19 statements  

« prev     ^ index     » next       coverage.py v7.4.1, created at 2024-02-04 15:10:26 +00:00

1"""Cross the bridge back from the Nineties.""" 

2 

3import os 

4import pathlib 

5import sys 

6 

7import aikasilta.bridge as tb 

8 

9DEBUG_VAR = 'AIKASILTA_DEBUG' 

10DEBUG = bool(os.getenv(DEBUG_VAR, '')) 

11 

12ABORT_VAR = 'AIKASILTA_ABORT' 

13ABORT = bool(os.getenv(ABORT_VAR)) 

14 

15 

16def main(argv: list[str] | None = None, abort: bool | None = None, debug: bool | None = None) -> int: 

17 """Dispatch processing of the job. 

18 This is the strings only command line interface. 

19 For python API use interact with lint functions directly. 

20 """ 

21 argv = sys.argv[1:] if argv is None else argv 

22 debug = debug if debug else DEBUG 

23 abort = abort if abort else ABORT 

24 unique_trees = {arg: None for arg in argv} 

25 for tree_or_leaf in unique_trees: 25 ↛ 30line 25 didn't jump to line 30, because the loop on line 25 didn't complete

26 if not pathlib.Path(tree_or_leaf).is_file() and not pathlib.Path(tree_or_leaf).is_dir(): 26 ↛ 25line 26 didn't jump to line 25, because the condition on line 26 was never false

27 print('ERROR: For now only existing paths accepted.') 

28 sys.exit(2) 

29 

30 code, _ = tb.main(unique_trees, abort=abort, debug=debug) 

31 return code