-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
38 lines (32 loc) · 829 Bytes
/
cli.py
File metadata and controls
38 lines (32 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from decomment import *
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"--mode",
"-m",
action="store",
choices=["decomment", "recomment"]
)
parser.add_argument(
"--file",
"-f",
action="store",
help="Filename or path to the target file",
nargs="?"
)
args = parser.parse_args()
fname = args.file
# args.mode = 'decomment'
# fname = 'code.py'
if __name__ == '__main__':
ext = fname[fname.find('.')+1:]
match(ext):
case 'py':
if args.mode == 'decomment':
print(f'Decommenting {fname}...')
dc_python(fname)
elif args.mode == 'recomment':
print(f'Recommenting {fname}...')
rc_python(fname)
case _:
print(f'Filetype "{ext}" not supported.')