|
10 | 10 | from pydantic.json_schema import models_json_schema
|
11 | 11 |
|
12 | 12 | from . import pdl_interpreter
|
| 13 | +from ._version import version |
13 | 14 | from .pdl_ast import (
|
14 | 15 | LocationType,
|
15 | 16 | PdlBlock,
|
@@ -148,50 +149,59 @@ def main():
|
148 | 149 | parser.add_argument(
|
149 | 150 | "--sandbox",
|
150 | 151 | action=argparse.BooleanOptionalAction,
|
151 |
| - help="run the interpreter in a container. A docker daemon must be running.", |
| 152 | + help="run the interpreter in a container, a docker daemon must be running", |
152 | 153 | )
|
153 |
| - parser.add_argument( |
154 |
| - "--schema", |
155 |
| - action=argparse.BooleanOptionalAction, |
156 |
| - help="generate PDL Json Schema", |
157 |
| - ) |
158 |
| - parser.add_argument( |
159 |
| - "-l", |
160 |
| - "--log", |
161 |
| - help="log file", |
162 |
| - ) |
163 |
| - |
164 | 154 | parser.add_argument(
|
165 | 155 | "-f",
|
166 | 156 | "--data-file",
|
167 | 157 | dest="data_file",
|
168 |
| - help="initial scope data file", |
| 158 | + help="file containing initial values to add to the scope", |
169 | 159 | )
|
170 |
| - |
171 | 160 | parser.add_argument(
|
172 | 161 | "-d",
|
173 | 162 | "--data",
|
174 |
| - help="scope data", |
| 163 | + help="initial values to add to the scope", |
175 | 164 | )
|
176 |
| - |
177 | 165 | parser.add_argument(
|
178 | 166 | "--stream",
|
179 | 167 | choices=["result", "background", "none"],
|
180 | 168 | default="result",
|
181 |
| - help="stream the result or the background messages on the standard output", |
| 169 | + help="stream the result, the background messages, or nothing on the standard output", |
182 | 170 | )
|
183 |
| - |
184 | 171 | parser.add_argument(
|
185 | 172 | "-t",
|
186 | 173 | "--trace",
|
187 | 174 | nargs="?",
|
188 | 175 | const="*_trace.json",
|
189 |
| - help="output trace for live document", |
| 176 | + help="output trace for live document and optionally specify the file name", |
190 | 177 | )
|
| 178 | + parser.add_argument( |
| 179 | + "-l", |
| 180 | + "--log", |
| 181 | + help="specify a name for the log file", |
| 182 | + ) |
| 183 | + parser.add_argument( |
| 184 | + "--schema", |
| 185 | + action="store_true", |
| 186 | + help="generate PDL Json Schema and exit", |
| 187 | + default=False, |
| 188 | + ) |
| 189 | + parser.add_argument( |
| 190 | + "--version", |
| 191 | + action="store_true", |
| 192 | + help="print the version number and exit", |
| 193 | + default=False, |
| 194 | + ) |
| 195 | + |
191 | 196 | parser.add_argument("pdl", nargs="?", help="pdl file", type=str)
|
192 | 197 |
|
193 | 198 | args = parser.parse_args()
|
194 | 199 |
|
| 200 | + # This case must be before `if args.pdl is None:` |
| 201 | + if args.version: |
| 202 | + print(f"PDL {version}") |
| 203 | + return |
| 204 | + |
195 | 205 | # This case must be before `if args.pdl is None:`
|
196 | 206 | if args.schema:
|
197 | 207 | schema, top_level_schema = models_json_schema(
|
|
0 commit comments