1
1
mirror of https://github.com/chubin/cheat.sh.git synced 2024-12-12 16:04:57 +03:00
cheat.sh/lib/options.py

39 lines
891 B
Python
Raw Normal View History

2018-05-05 15:04:06 +03:00
"""
Parse query arguments.
"""
def parse_args(args):
"""
Parse arguments and options.
Replace short options with their long counterparts.
"""
2018-05-06 20:35:01 +03:00
result = {
'add_comments': True,
}
2018-05-05 15:04:06 +03:00
query = ""
for key, val in args.items():
if val == "" or val == []:
query += key
continue
options_meaning = {
2018-05-06 20:35:01 +03:00
"c": dict(add_comments=False, unindent_code=False),
"C": dict(add_comments=False, unindent_code=True),
2018-05-05 15:04:06 +03:00
"Q": dict(remove_text=True),
2018-05-06 20:35:01 +03:00
'q': dict(quiet=True),
'T': {'no-terminal': True},
2018-05-05 15:04:06 +03:00
}
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