9
9
import typing as t
10
10
11
11
import yaml
12
+ from colorama import Fore , Style
12
13
13
14
from vcspull .config import expand_dir , find_home_config_files , save_config_yaml
14
15
@@ -113,8 +114,9 @@ def add_from_filesystem(
113
114
if not home_configs :
114
115
config_file_path = pathlib .Path .cwd () / ".vcspull.yaml"
115
116
log .info (
116
- f"No config specified and no default home config, will use/create "
117
- f"{ config_file_path } " ,
117
+ f"{ Fore .CYAN } i{ Style .RESET_ALL } No config specified and no default "
118
+ f"home config, will use/create "
119
+ f"{ Fore .BLUE } { config_file_path } { Style .RESET_ALL } "
118
120
)
119
121
elif len (home_configs ) > 1 :
120
122
log .error (
@@ -144,7 +146,9 @@ def add_from_filesystem(
144
146
return
145
147
else :
146
148
log .info (
147
- f"Config file { config_file_path } not found. A new one will be created." ,
149
+ f"{ Fore .CYAN } i{ Style .RESET_ALL } Config file "
150
+ f"{ Fore .BLUE } { config_file_path } { Style .RESET_ALL } "
151
+ f"not found. A new one will be created."
148
152
)
149
153
150
154
found_repos : list [
@@ -218,7 +222,10 @@ def add_from_filesystem(
218
222
found_repos .append ((repo_name , repo_url , determined_base_key ))
219
223
220
224
if not found_repos :
221
- log .info (f"No git repositories found in { scan_dir } . Nothing to add." )
225
+ log .info (
226
+ f"{ Fore .YELLOW } !{ Style .RESET_ALL } No git repositories found in "
227
+ f"{ Fore .BLUE } { scan_dir } { Style .RESET_ALL } . Nothing to add."
228
+ )
222
229
return
223
230
224
231
repos_to_add : list [tuple [str , str , str ]] = []
@@ -232,22 +239,33 @@ def add_from_filesystem(
232
239
repos_to_add .append ((name , url , key ))
233
240
234
241
if existing_repos :
235
- log .info (f"Found { len (existing_repos )} existing repositories in configuration:" )
242
+ log .info (
243
+ f"{ Fore .YELLOW } !{ Style .RESET_ALL } Found "
244
+ f"{ Fore .CYAN } { len (existing_repos )} { Style .RESET_ALL } "
245
+ f"existing repositories in configuration:"
246
+ )
236
247
for name , url , key in existing_repos :
237
- log .info (f" - { name } ({ url } ) at { key } { name } in { config_file_path } " )
248
+ log .info (
249
+ f" { Fore .BLUE } •{ Style .RESET_ALL } { Fore .CYAN } { name } { Style .RESET_ALL } "
250
+ f"({ Fore .YELLOW } { url } { Style .RESET_ALL } ) at "
251
+ f"{ Fore .MAGENTA } { key } { name } { Style .RESET_ALL } "
252
+ f"in { Fore .BLUE } { config_file_path } { Style .RESET_ALL } "
253
+ )
238
254
239
255
if not repos_to_add :
240
256
if existing_repos :
241
257
log .info (
242
- " All found repositories already exist in the configuration. "
243
- " Nothing to do."
258
+ f" { Fore . GREEN } ✓ { Style . RESET_ALL } All found repositories already exist "
259
+ f"in the configuration. { Fore . GREEN } Nothing to do.{ Style . RESET_ALL } "
244
260
)
245
261
return
246
262
247
263
if not yes :
248
- confirm = input ("Add these repositories? [y/N]: " ).lower ()
264
+ confirm = input (
265
+ f"{ Fore .CYAN } Add these repositories? [y/N]: { Style .RESET_ALL } "
266
+ ).lower ()
249
267
if confirm not in {"y" , "yes" }:
250
- log .info (" Aborted by user." )
268
+ log .info (f" { Fore . RED } ✗ { Style . RESET_ALL } Aborted by user." )
251
269
return
252
270
253
271
changes_made = False
@@ -264,14 +282,20 @@ def add_from_filesystem(
264
282
if repo_name not in raw_config [determined_base_key ]:
265
283
raw_config [determined_base_key ][repo_name ] = repo_url
266
284
log .info (
267
- f"Adding '{ repo_name } ' ({ repo_url } ) under '{ determined_base_key } '." ,
285
+ f"{ Fore .GREEN } +{ Style .RESET_ALL } Adding "
286
+ f"{ Fore .CYAN } '{ repo_name } '{ Style .RESET_ALL } "
287
+ f"({ Fore .YELLOW } { repo_url } { Style .RESET_ALL } ) under "
288
+ f"'{ Fore .MAGENTA } { determined_base_key } { Style .RESET_ALL } '."
268
289
)
269
290
changes_made = True
270
291
271
292
if changes_made :
272
293
try :
273
294
save_config_yaml (config_file_path , raw_config )
274
- log .info (f"Successfully updated { config_file_path } ." )
295
+ log .info (
296
+ f"{ Fore .GREEN } ✓{ Style .RESET_ALL } Successfully updated "
297
+ f"{ Fore .BLUE } { config_file_path } { Style .RESET_ALL } ."
298
+ )
275
299
except Exception :
276
300
log .exception (f"Error saving config to { config_file_path } " )
277
301
if log .isEnabledFor (logging .DEBUG ):
@@ -280,4 +304,6 @@ def add_from_filesystem(
280
304
traceback .print_exc ()
281
305
raise
282
306
else :
283
- log .info ("No changes made to the configuration." )
307
+ log .info (
308
+ f"{ Fore .GREEN } ✓{ Style .RESET_ALL } No changes made to the configuration."
309
+ )
0 commit comments