Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

A minimal, idiomatic Python library for working with **GTS** ([Global Type System](https://github.com/gts-spec/gts-spec)) identifiers and JSON/JSON Schema artifacts.

## Roadmap
Current supported GTS spec version: `0.13.1`

Current supported GTS spec version: 0.13
## Roadmap

Featureset:

Expand Down
2 changes: 1 addition & 1 deletion gts/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openapi": "3.1.0",
"info": {
"title": "GTS Server",
"version": "0.13.0"
"version": "0.13.1"
},
"paths": {
"/entities": {
Expand Down
2 changes: 1 addition & 1 deletion gts/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "gts"
version = "0.13.0"
version = "0.13.1"
description = "Global Type System (GTS) helpers: identifiers, parsing, validation, and operations"
readme = "README.md"
authors = [{ name = "GTS Community" }]
Expand Down
35 changes: 34 additions & 1 deletion gts/src/gts/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
import sys

from ._json_validation import GtsJsonValidator
from ._server import GtsHttpServer
from .ops import GtsOps

Expand All @@ -18,6 +19,14 @@ def build_parser() -> argparse.ArgumentParser:
p.add_argument(
"--path", help="Path to json and schema files or directories (global default)"
)
p.add_argument(
"--exclude",
default="node_modules,dist,build,.git,target",
help=(
"Comma-separated directory names to exclude when scanning "
"(default: node_modules,dist,build,.git,target)"
),
)
sub = p.add_subparsers(dest="op", required=True)

s = sub.add_parser("validate-id", help="Validate a GTS ID format")
Expand All @@ -34,6 +43,11 @@ def build_parser() -> argparse.ArgumentParser:
s.add_argument("--gts-id", required=True)
s.add_argument("--scope", choices=["major", "full"], default="major")

s = sub.add_parser(
"validate-all", help="Validate all JSON documents in a file or directory"
)
s.add_argument("--path", dest="scan_path", help="JSON file or directory to scan")

s = sub.add_parser(
"validate-instance", help="Validate an instance against its schema"
)
Expand Down Expand Up @@ -116,8 +130,16 @@ def main(argv: list[str] | None = None) -> None:
)

try:
# Parse the comma-separated --exclude option into a list of dir names
exclude = [e.strip() for e in (args.exclude or "").split(",") if e.strip()]

# Helper to create GtsOps with common arguments
ops = GtsOps(path=args.path, config=args.config, verbose=args.verbose)
ops = GtsOps(
path=args.path,
config=args.config,
verbose=args.verbose,
exclude=exclude,
)

if args.op == "server":
server = GtsHttpServer(ops=ops)
Expand Down Expand Up @@ -146,6 +168,17 @@ def main(argv: list[str] | None = None) -> None:
json.dump(out, sys.stdout, ensure_ascii=False, indent=2)
sys.stdout.write("\n")
return
elif args.op == "validate-all":
scan_path = args.scan_path or args.path
if not scan_path:
parser.error("validate-all requires --path")
result = GtsJsonValidator(scan_path, ops.cfg, exclude=exclude).validate()
out = result.to_dict()
Comment thread
coderabbitai[bot] marked this conversation as resolved.
json.dump(out, sys.stdout, ensure_ascii=False, indent=2)
sys.stdout.write("\n")
if not result.ok:
raise SystemExit(1)
return
elif args.op == "validate-id":
out = ops.validate_id(args.gts_id).to_dict()
elif args.op == "parse-id":
Expand Down
Loading
Loading