Skip to content

Commit b10df37

Browse files
calvingilesclaude
andauthored
feat: Add --builtin-types flag and rename default type dir (#38)
This commit adds two improvements to the validate-dsl command: 1. **New `--builtin-types` flag**: Allows using built-in types (Job, Requirement, ADR) without requiring a custom type directory. This makes it easier to get started with DSL validation. 2. **Renamed default type directory**: Changed from `.spec-types` to `spec_types` for Python package name validity. The dot prefix made it an invalid Python package name. **Changes:** - Added `--builtin-types` / `-b` flag to CLI - Updated `cmd_validate_dsl()` to load builtin types when flag is set - Changed default `--type-dir` from `.spec-types` to `spec_types` - Updated help text examples to reflect new options **Usage:** ```bash # Use built-in types spec-check validate-dsl --builtin-types specs/ # Use custom types (new default location) spec-check validate-dsl --type-dir spec_types/ ``` **Testing:** - All 274 tests pass - Manually tested new --builtin-types flag - Help text displays correctly 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent dfe6702 commit b10df37

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

spec_check/cli.py

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,19 @@ def cmd_validate_dsl(args) -> int:
255255
Exit code (0 for success, 1 for failure).
256256
"""
257257
try:
258-
# Type definitions directory
259-
type_dir = Path(args.type_dir)
260-
if not type_dir.exists():
261-
print(f"Error: Type definitions directory not found: {type_dir}", file=sys.stderr)
262-
return 1
263-
264258
# Load type definitions
265-
registry = SpecTypeRegistry.load_from_package(type_dir)
259+
if args.builtin_types:
260+
# Use built-in types (Job, Requirement, ADR)
261+
registry = SpecTypeRegistry.load_builtin_types()
262+
if args.verbose:
263+
print("Using built-in type definitions (Job, Requirement, ADR)")
264+
else:
265+
# Load from custom type directory
266+
type_dir = Path(args.type_dir)
267+
if not type_dir.exists():
268+
print(f"Error: Type definitions directory not found: {type_dir}", file=sys.stderr)
269+
return 1
270+
registry = SpecTypeRegistry.load_from_package(type_dir)
266271

267272
if args.verbose:
268273
print(f"Loaded {len(registry.modules)} module type(s)")
@@ -733,14 +738,17 @@ def test_combined():
733738
formatter_class=argparse.RawDescriptionHelpFormatter,
734739
epilog="""
735740
Examples:
736-
# Validate documents using type definitions in .spec-types
741+
# Validate using built-in types (Job, Requirement, ADR)
742+
spec-check validate-dsl --builtin-types specs/
743+
744+
# Validate documents using type definitions in spec_types/
737745
spec-check validate-dsl
738746
739747
# Validate specific directory
740748
spec-check validate-dsl specs/
741749
742750
# Use custom type definitions directory
743-
spec-check validate-dsl --type-dir my-types/
751+
spec-check validate-dsl --type-dir my_types/
744752
745753
How it works:
746754
The DSL validator implements a multi-pass validation architecture:
@@ -760,7 +768,7 @@ def test_combined():
760768
- Reference constraints (cardinality, type checking)
761769
762770
Directory structure:
763-
.spec-types/
771+
spec_types/
764772
config.yaml # Global configuration
765773
modules/
766774
requirement.yaml # Module type definitions
@@ -793,8 +801,15 @@ def test_combined():
793801
validate_dsl_parser.add_argument(
794802
"--type-dir",
795803
"-t",
796-
default=".spec-types",
797-
help="Path to type definitions directory (default: .spec-types)",
804+
default="spec_types",
805+
help="Path to type definitions directory (default: spec_types)",
806+
)
807+
808+
validate_dsl_parser.add_argument(
809+
"--builtin-types",
810+
"-b",
811+
action="store_true",
812+
help="Use built-in types (Job, Requirement, ADR) instead of custom types",
798813
)
799814

800815
validate_dsl_parser.add_argument(

0 commit comments

Comments
 (0)