From fe3729eef7518e2ee2ebd46b4c70a371af46fed1 Mon Sep 17 00:00:00 2001 From: "Sam G." Date: Fri, 5 Jul 2024 04:11:54 -0700 Subject: [PATCH] improve output formatting --- Makefile | 24 +++++++++++------------- symconf/__main__.py | 1 - symconf/config.py | 40 ++++++++++++++++++++++++++-------------- 3 files changed, 37 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index a1131d3..4af189f 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,9 @@ endif ## ------------------ docs ------------------ ## +docs-publish: + scp -r docs/_build/html/* hetz-cloud:/var/www/doc.olog.io/symconf/ + docs-serve: cd docs/_build/html && python -m http.server 9091 @@ -19,23 +22,18 @@ docs-clean: make -C docs/ clean rm -rf docs/_autoref rm -rf docs/_autosummary - ## ------------------------------------------ ## -## ------------------ sync ------------------ ## -sync: - $(BASH) autoconf/sync.sh +## ----------------- tests ------------------ ## +test: + pytest --pyargs tests -v ## ------------------------------------------ ## +## ----------------- build ------------------ ## +build: + python -m build -## ----------------- themes ----------------- ## -gen-tone4: - $(PYTHON) autoconf/gen_theme.py -a kitty -p tone4 - -set-tone4-light: - $(PYTHON) autoconf/set_theme.py -p tone4 -s light -a "*" - -set-tone4-dark: - $(PYTHON) autoconf/set_theme.py -p tone4 -s dark -a "*" +publish: + python -m twine upload dist/* ## ------------------------------------------ ## diff --git a/symconf/__main__.py b/symconf/__main__.py index da493be..5870d1d 100644 --- a/symconf/__main__.py +++ b/symconf/__main__.py @@ -94,7 +94,6 @@ add_set_subparser(subparsers) if __name__ == '__main__': args = parser.parse_args() - print(args) if 'func' in args: args.func(args) diff --git a/symconf/config.py b/symconf/config.py index dc2dee1..8957fb0 100644 --- a/symconf/config.py +++ b/symconf/config.py @@ -424,6 +424,8 @@ class ConfigManager: full_path, # to internal config location )) + print('├─ ' + Fore.YELLOW + f'{app_name} :: matched {len(to_symlink)} config files') + links_succ = [] links_fail = [] for from_path, to_path in to_symlink: @@ -455,6 +457,17 @@ class ConfigManager: from_path.symlink_to(to_path) links_succ.append((from_path, to_path)) + # link report + for from_p, to_p in links_succ: + from_p = from_p + to_p = to_p.relative_to(self.config_dir) + print(Fore.GREEN + f'│ > linked {from_p} -> {to_p}') + + for from_p, to_p in links_fail: + from_p = from_p + to_p = to_p.relative_to(self.config_dir) + print(Fore.RED + f'│ > failed to link {from_p} -> {to_p}') + # run matching scripts for app-specific reload script_list = self.get_matching_scripts( app_name, @@ -463,21 +476,15 @@ class ConfigManager: ) for script in script_list: - print(Fore.BLUE + f'> Running script "{script.relative_to(self.config_dir)}"') + print(Fore.BLUE + f'│ > running script "{script.relative_to(self.config_dir)}"') output = subprocess.check_output(str(script), shell=True) - print( - Fore.BLUE + Style.DIM + f'-> Captured script output "{output.decode().strip()}"' + Style.RESET_ALL - ) - - for from_p, to_p in links_succ: - from_p = from_p - to_p = to_p.relative_to(self.config_dir) - print(Fore.GREEN + f'> {app_name} :: {from_p} -> {to_p}') - - for from_p, to_p in links_fail: - from_p = from_p - to_p = to_p.relative_to(self.config_dir) - print(Fore.RED + f'> {app_name} :: {from_p} -> {to_p}') + if output: + fmt_output = output.decode().strip().replace('\n','\n│ ') + print( + Fore.BLUE + Style.DIM \ + + f'│ > captured script output "{fmt_output}"' \ + + Style.RESET_ALL + ) def update_apps( self, @@ -496,6 +503,11 @@ class ConfigManager: print(f'None of the apps "{apps}" are registered, exiting') return + print('> symconf parameters: ') + print(' > registered apps :: ' + Fore.YELLOW + f'{app_list}' + Style.RESET_ALL) + print(' > palette :: ' + Fore.YELLOW + f'{palette}' + Style.RESET_ALL) + print(' > scheme :: ' + Fore.YELLOW + f'{scheme}\n' + Style.RESET_ALL) + for app_name in app_list: self.update_app_config( app_name,