MCPcopy Create free account
hub / github.com/Notgnoshi/generative / parse_args

Function parse_args

tools/parse-production-rules.py:39–102  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37
38
39def parse_args():
40 parser = argparse.ArgumentParser(
41 description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
42 )
43
44 parser.add_argument(
45 "-c",
46 "--config",
47 type=argparse.FileType("r"),
48 default=None,
49 help="The JSON config file as described above. Uses stdin if '-' is given. Commandline arguments, if given, will override the values in the config file.",
50 )
51 parser.add_argument(
52 "output",
53 nargs="?",
54 type=argparse.FileType("w"),
55 default=sys.stdout,
56 help="A file to output the expanded axiom to. Defaults to stdout.",
57 )
58 parser.add_argument(
59 "--long-tokens",
60 "-L",
61 action="store_true",
62 default=False,
63 help="Whether to support comma/whitespace separate long tokens. Otherwise assume single character tokens. Parser output will be space-separated in this mode.",
64 )
65 parser.add_argument(
66 "-r",
67 "--rule",
68 type=str,
69 default=[],
70 action="append",
71 help="Add the given production rule. Multiple '--rule's can be given. Uses the same syntax as the config file.",
72 )
73 parser.add_argument(
74 "-a",
75 "--axiom",
76 type=str,
77 default=None,
78 help="The starting axiom to apply the production rules to.",
79 )
80 parser.add_argument(
81 "-n",
82 "--iterations",
83 type=int,
84 default=None,
85 help="The number of iterations to run.",
86 )
87 parser.add_argument(
88 "--seed",
89 type=int,
90 default=None,
91 help="The random seed to use for stochastic grammars. If not given, one will be chosen and printed to stderr.",
92 )
93 parser.add_argument(
94 "-l",
95 "--log-level",
96 type=str,

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected