Skip to content

Commit 1bad6b1

Browse files
committed
feat: 🎸 add progressbar
Closes: #9
1 parent 6273274 commit 1bad6b1

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

pyencrypt/cli.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def encrypt_command(ctx, pathname, delete, key):
9090
ctx.fail(f'Your encryption key is invalid.')
9191
if key is None:
9292
key = generate_aes_key().decode()
93-
click.echo(f'Your randomly encryption key is {key}')
93+
click.echo(f'Your randomly encryption 🔑 is {key}')
9494

9595
path = Path(pathname)
9696
work_dir = Path(os.getcwd()) / 'encrypted' / 'src'
@@ -103,12 +103,13 @@ def encrypt_command(ctx, pathname, delete, key):
103103
shutil.copytree(path, work_dir)
104104
files = set(path.glob('**/*.py')) - set(
105105
path.glob(f'encrypted/**/*.py'))
106-
for file in files:
107-
if can_encrypt(file):
108-
print(file)
109-
new_path = work_dir / file.relative_to(path)
110-
new_path.unlink()
111-
encrypt_file(file, key, delete, new_path.with_suffix('.pye'))
106+
with click.progressbar(files, label='🔐 Encrypting') as bar:
107+
for file in bar:
108+
if can_encrypt(file):
109+
new_path = work_dir / file.relative_to(path)
110+
new_path.unlink()
111+
encrypt_file(file, key, delete,
112+
new_path.with_suffix('.pye'))
112113
else:
113114
raise Exception(f'{path} is not a valid path.')
114115

@@ -139,10 +140,10 @@ def decrypt_command(pathname, key):
139140
work_dir.exists() and shutil.rmtree(work_dir)
140141
shutil.copytree(path, work_dir)
141142
files = list(path.glob('**/*.pye'))
142-
for file in files:
143-
print(file)
144-
new_path = work_dir / file.relative_to(path)
145-
decrypt_file(file, key, new_path)
143+
with click.progressbar(files, label='🔓 Decrypting') as bar:
144+
for file in files:
145+
new_path = work_dir / file.relative_to(path)
146+
decrypt_file(file, key, new_path)
146147
else:
147148
raise Exception(f'{path} is not a valid path.')
148149

0 commit comments

Comments
 (0)