Skip to content

Commit

Permalink
Add --version and remove --no-schema to the command line options (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mandel authored Oct 1, 2024
1 parent f8f0817 commit 5203747
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions src/pdl/pdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pydantic.json_schema import models_json_schema

from . import pdl_interpreter
from ._version import version
from .pdl_ast import (
LocationType,
PdlBlock,
Expand Down Expand Up @@ -148,50 +149,59 @@ def main():
parser.add_argument(
"--sandbox",
action=argparse.BooleanOptionalAction,
help="run the interpreter in a container. A docker daemon must be running.",
help="run the interpreter in a container, a docker daemon must be running",
)
parser.add_argument(
"--schema",
action=argparse.BooleanOptionalAction,
help="generate PDL Json Schema",
)
parser.add_argument(
"-l",
"--log",
help="log file",
)

parser.add_argument(
"-f",
"--data-file",
dest="data_file",
help="initial scope data file",
help="file containing initial values to add to the scope",
)

parser.add_argument(
"-d",
"--data",
help="scope data",
help="initial values to add to the scope",
)

parser.add_argument(
"--stream",
choices=["result", "background", "none"],
default="result",
help="stream the result or the background messages on the standard output",
help="stream the result, the background messages, or nothing on the standard output",
)

parser.add_argument(
"-t",
"--trace",
nargs="?",
const="*_trace.json",
help="output trace for live document",
help="output trace for live document and optionally specify the file name",
)
parser.add_argument(
"-l",
"--log",
help="specify a name for the log file",
)
parser.add_argument(
"--schema",
action="store_true",
help="generate PDL Json Schema and exit",
default=False,
)
parser.add_argument(
"--version",
action="store_true",
help="print the version number and exit",
default=False,
)

parser.add_argument("pdl", nargs="?", help="pdl file", type=str)

args = parser.parse_args()

# This case must be before `if args.pdl is None:`
if args.version:
print(f"PDL {version}")
return

# This case must be before `if args.pdl is None:`
if args.schema:
schema, top_level_schema = models_json_schema(
Expand Down

0 comments on commit 5203747

Please sign in to comment.