MCPcopy Create free account
hub / github.com/chubin/cheat.sh / parse_args

Function parse_args

lib/options.py:6–40  ·  view source on GitHub ↗

Parse arguments and options. Replace short options with their long counterparts.

(args)

Source from the content-addressed store, hash-verified

4
5
6def parse_args(args):
7 """
8 Parse arguments and options.
9 Replace short options with their long counterparts.
10 """
11 result = {
12 "add_comments": True,
13 }
14
15 query = ""
16 newargs = {}
17 for key, val in args.items():
18 if val == "" or val == [] or val == [""]:
19 query += key
20 continue
21 if val == "True":
22 val = True
23 if val == "False":
24 val = False
25 newargs[key] = val
26
27 options_meaning = {
28 "c": dict(add_comments=False, unindent_code=False),
29 "C": dict(add_comments=False, unindent_code=True),
30 "Q": dict(remove_text=True),
31 "q": dict(quiet=True),
32 "T": {"no-terminal": True},
33 }
34 for option, meaning in options_meaning.items():
35 if option in query:
36 result.update(meaning)
37
38 result.update(newargs)
39
40 return result

Callers 1

answerFunction · 0.90

Calls 1

updateMethod · 0.80

Tested by

no test coverage detected