improve output formatting

This commit is contained in:
Sam G. 2024-07-05 04:11:54 -07:00
parent 6c01071f04
commit fe3729eef7
3 changed files with 37 additions and 28 deletions

View File

@ -8,6 +8,9 @@ endif
## ------------------ docs ------------------ ## ## ------------------ docs ------------------ ##
docs-publish:
scp -r docs/_build/html/* hetz-cloud:/var/www/doc.olog.io/symconf/
docs-serve: docs-serve:
cd docs/_build/html && python -m http.server 9091 cd docs/_build/html && python -m http.server 9091
@ -19,23 +22,18 @@ docs-clean:
make -C docs/ clean make -C docs/ clean
rm -rf docs/_autoref rm -rf docs/_autoref
rm -rf docs/_autosummary rm -rf docs/_autosummary
## ------------------------------------------ ## ## ------------------------------------------ ##
## ------------------ sync ------------------ ## ## ----------------- tests ------------------ ##
sync: test:
$(BASH) autoconf/sync.sh pytest --pyargs tests -v
## ------------------------------------------ ## ## ------------------------------------------ ##
## ----------------- build ------------------ ##
build:
python -m build
## ----------------- themes ----------------- ## publish:
gen-tone4: python -m twine upload dist/*
$(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 "*"
## ------------------------------------------ ## ## ------------------------------------------ ##

View File

@ -94,7 +94,6 @@ add_set_subparser(subparsers)
if __name__ == '__main__': if __name__ == '__main__':
args = parser.parse_args() args = parser.parse_args()
print(args)
if 'func' in args: if 'func' in args:
args.func(args) args.func(args)

View File

@ -424,6 +424,8 @@ class ConfigManager:
full_path, # to internal config location full_path, # to internal config location
)) ))
print('├─ ' + Fore.YELLOW + f'{app_name} :: matched {len(to_symlink)} config files')
links_succ = [] links_succ = []
links_fail = [] links_fail = []
for from_path, to_path in to_symlink: for from_path, to_path in to_symlink:
@ -455,6 +457,17 @@ class ConfigManager:
from_path.symlink_to(to_path) from_path.symlink_to(to_path)
links_succ.append((from_path, 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 # run matching scripts for app-specific reload
script_list = self.get_matching_scripts( script_list = self.get_matching_scripts(
app_name, app_name,
@ -463,21 +476,15 @@ class ConfigManager:
) )
for script in script_list: 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) output = subprocess.check_output(str(script), shell=True)
print( if output:
Fore.BLUE + Style.DIM + f'-> Captured script output "{output.decode().strip()}"' + Style.RESET_ALL fmt_output = output.decode().strip().replace('\n','\n')
) print(
Fore.BLUE + Style.DIM \
for from_p, to_p in links_succ: + f'│ > captured script output "{fmt_output}"' \
from_p = from_p + Style.RESET_ALL
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}')
def update_apps( def update_apps(
self, self,
@ -496,6 +503,11 @@ class ConfigManager:
print(f'None of the apps "{apps}" are registered, exiting') print(f'None of the apps "{apps}" are registered, exiting')
return 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: for app_name in app_list:
self.update_app_config( self.update_app_config(
app_name, app_name,