Skip to content

Commit 5203747

Browse files
authored
Add --version and remove --no-schema to the command line options (#111)
1 parent f8f0817 commit 5203747

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

src/pdl/pdl.py

+29-19
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pydantic.json_schema import models_json_schema
1111

1212
from . import pdl_interpreter
13+
from ._version import version
1314
from .pdl_ast import (
1415
LocationType,
1516
PdlBlock,
@@ -148,50 +149,59 @@ def main():
148149
parser.add_argument(
149150
"--sandbox",
150151
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",
152153
)
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-
164154
parser.add_argument(
165155
"-f",
166156
"--data-file",
167157
dest="data_file",
168-
help="initial scope data file",
158+
help="file containing initial values to add to the scope",
169159
)
170-
171160
parser.add_argument(
172161
"-d",
173162
"--data",
174-
help="scope data",
163+
help="initial values to add to the scope",
175164
)
176-
177165
parser.add_argument(
178166
"--stream",
179167
choices=["result", "background", "none"],
180168
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",
182170
)
183-
184171
parser.add_argument(
185172
"-t",
186173
"--trace",
187174
nargs="?",
188175
const="*_trace.json",
189-
help="output trace for live document",
176+
help="output trace for live document and optionally specify the file name",
190177
)
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+
191196
parser.add_argument("pdl", nargs="?", help="pdl file", type=str)
192197

193198
args = parser.parse_args()
194199

200+
# This case must be before `if args.pdl is None:`
201+
if args.version:
202+
print(f"PDL {version}")
203+
return
204+
195205
# This case must be before `if args.pdl is None:`
196206
if args.schema:
197207
schema, top_level_schema = models_json_schema(

0 commit comments

Comments
 (0)