mirror of
https://github.com/chubin/cheat.sh.git
synced 2024-12-13 05:14:52 +03:00
moved args parsers to lib/options.py
This commit is contained in:
parent
09e6a4558f
commit
4782436462
39
lib/options.py
Normal file
39
lib/options.py
Normal file
@ -0,0 +1,39 @@
|
||||
"""
|
||||
Parse query arguments.
|
||||
"""
|
||||
|
||||
def parse_args(args):
|
||||
"""
|
||||
Parse arguments and options.
|
||||
Replace short options with their long counterparts.
|
||||
"""
|
||||
result = {}
|
||||
|
||||
query = ""
|
||||
for key, val in args.items():
|
||||
if val == "" or val == []:
|
||||
query += key
|
||||
continue
|
||||
|
||||
if 'T' in query:
|
||||
result['no-terminal'] = True
|
||||
if 'q' in query:
|
||||
result['quiet'] = True
|
||||
|
||||
options_meaning = {
|
||||
"c": dict(add_comments=True),
|
||||
"C": dict(add_comments=False),
|
||||
"Q": dict(remove_text=True),
|
||||
}
|
||||
for option, meaning in options_meaning.items():
|
||||
if option in query:
|
||||
result.update(meaning)
|
||||
|
||||
for key, val in args.items():
|
||||
if val == 'True':
|
||||
val = True
|
||||
if val == 'False':
|
||||
val = False
|
||||
result[key] = val
|
||||
|
||||
return result
|
Loading…
Reference in New Issue
Block a user