Skip to content

Commit 222a9fb

Browse files
committed
Improve command line interface
1 parent f30b7b2 commit 222a9fb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

mypy/exportjson.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import argparse
1717
import json
18+
import sys
1819
from typing import Any, Union
1920
from typing_extensions import TypeAlias as _TypeAlias
2021

@@ -552,11 +553,18 @@ def convert_unbound_type(self: UnboundType) -> Json:
552553

553554

554555
def main() -> None:
555-
parser = argparse.ArgumentParser()
556-
parser.add_argument("path", nargs="+")
556+
parser = argparse.ArgumentParser(
557+
description="Convert binary cache files to JSON. "
558+
"Create files in the same directory with extra .json extension."
559+
)
560+
parser.add_argument(
561+
"path", nargs="+", help="mypy cache data file to convert (.data.ff extension)"
562+
)
557563
args = parser.parse_args()
558564
fnams: list[str] = args.path
559565
for fnam in fnams:
566+
if not fnam.endswith(".data.ff"):
567+
sys.exit(f"error: Expected .data.ff extension, but got {fnam}")
560568
with open(fnam, "rb") as f:
561569
data = f.read()
562570
json_data = convert_binary_cache_to_json(data)

0 commit comments

Comments
 (0)