Skip to content

Commit de4f859

Browse files
committed
feat: 🎸 add progressbar
Closes: #9
1 parent 1e11c0d commit de4f859

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
@@ -88,7 +88,7 @@ def encrypt_command(ctx, pathname, delete, key):
8888
ctx.fail(f'Your encryption key is invalid.')
8989
if key is None:
9090
key = generate_aes_key().decode()
91-
click.echo(f'Your randomly encryption key is {key}')
91+
click.echo(f'Your randomly encryption 🔑 is {key}')
9292

9393
path = Path(pathname)
9494
work_dir = Path(os.getcwd()) / 'encrypted' / 'src'
@@ -101,12 +101,13 @@ def encrypt_command(ctx, pathname, delete, key):
101101
shutil.copytree(path, work_dir)
102102
files = set(path.glob('**/*.py')) - set(
103103
path.glob(f'encrypted/**/*.py'))
104-
for file in files:
105-
if can_encrypt(file):
106-
print(file)
107-
new_path = work_dir / file.relative_to(path)
108-
new_path.unlink()
109-
encrypt_file(file, key, delete, new_path.with_suffix('.pye'))
104+
with click.progressbar(files, label='🔐 Encrypting') as bar:
105+
for file in bar:
106+
if can_encrypt(file):
107+
new_path = work_dir / file.relative_to(path)
108+
new_path.unlink()
109+
encrypt_file(file, key, delete,
110+
new_path.with_suffix('.pye'))
110111
else:
111112
raise Exception(f'{path} is not a valid path.')
112113

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

0 commit comments

Comments
 (0)