| 35 | |
| 36 | |
| 37 | def parse_args(): |
| 38 | parser = argparse.ArgumentParser( |
| 39 | description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter |
| 40 | ) |
| 41 | |
| 42 | parser.add_argument( |
| 43 | "--input", |
| 44 | "-i", |
| 45 | type=argparse.FileType("r"), |
| 46 | default=sys.stdin, |
| 47 | help="A file containing the L-String to interpret. Defaults to stdin.", |
| 48 | ) |
| 49 | parser.add_argument( |
| 50 | "--output", |
| 51 | "-o", |
| 52 | # TODO: I seem to not be able to open stdout in binary mode. |
| 53 | # See: https://github.com/python/cpython/pull/13165 |
| 54 | # Potential workaround: open in 'wb' mode, and default to sys.stdout.buffer. |
| 55 | type=argparse.FileType("w"), |
| 56 | default=sys.stdout, |
| 57 | help="A file to output the expanded axiom to. Defaults to stdout.", |
| 58 | ) |
| 59 | parser.add_argument( |
| 60 | "--commandset", |
| 61 | "-c", |
| 62 | type=str, |
| 63 | default="default", |
| 64 | choices=LSystemInterpeter.commandsets, |
| 65 | help="The commandset to use to interpret the given L-String. Defaults to 'default'.", |
| 66 | ) |
| 67 | parser.add_argument( |
| 68 | "--stepsize", |
| 69 | "-s", |
| 70 | type=float, |
| 71 | default=1.0, |
| 72 | help="The step size for the turtle's forward motion. Defaults to 1.0.", |
| 73 | ) |
| 74 | parser.add_argument( |
| 75 | "--angle", |
| 76 | "-a", |
| 77 | type=float, |
| 78 | default=45.0, |
| 79 | help="The angle in degrees used for the turtle's orientation modifications. Defaults to 45.", |
| 80 | ) |
| 81 | parser.add_argument( |
| 82 | "--output-format", |
| 83 | "-O", |
| 84 | type=str, |
| 85 | default="wkt", |
| 86 | choices=["wkt", "wkb", "flat"], |
| 87 | help="The output format for the turtle path. Defaults to WKT.", |
| 88 | ) |
| 89 | parser.add_argument( |
| 90 | "-l", |
| 91 | "--log-level", |
| 92 | type=str, |
| 93 | default=DEFAULT_LEVEL, |
| 94 | choices=LOG_LEVELS.keys(), |