improve output formatting

This commit is contained in:
Sam G. 2024-07-05 04:11:54 -07:00
parent fd32cfd5ba
commit b72de8e28f
2 changed files with 26 additions and 15 deletions

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,