validate-inventory¶
This module validates a Fontshow inventory file against the project JSON Schema and runs semantic checks on language metadata.
It operates on an existing inventory file and does not modify it.
Responsibilities¶
- Load a Fontshow inventory from JSON
- Validate inventory structure against the schema
- Run semantic validation for language codes
- Report validation diagnostics to the CLI
Scope and non-responsibilities¶
The validate-inventory stage is responsible for checking whether an
inventory is structurally and semantically acceptable for downstream use.
It does not perform:
- font discovery
- font metadata extraction
- inventory enrichment or normalization
- catalog generation
- LaTeX compilation
In particular:
- the input inventory is treated as read-only
- validation diagnostics are emitted to the CLI only
- no output file is generated
This separation ensures that:
- validation remains explicit and repeatable
- inventory production and inventory checking stay decoupled
- downstream failures can be distinguished from input-data failures
Invocation¶
Use the top-level dispatcher:
fontshow validate-inventory <inventory.json>
The command validates an existing inventory file and exits after reporting the result.
Validation behavior¶
The command performs two layers of checks:
-
Schema validation Confirms that the inventory matches the Fontshow JSON Schema.
-
Semantic validation Reports invalid or suspicious language codes found in inventory metadata.
Semantic diagnostics are reported through the CLI and do not produce a new inventory artifact.
Output¶
On success, the command prints a confirmation message:
Schema validation passed.
On failure, it reports the detected problem, for example:
- missing input file
- invalid JSON
- schema validation failure
Semantic warnings are emitted before the final success message when the inventory is structurally valid but contains language-code issues.
Exit codes¶
| Code | Meaning |
|---|---|
0 |
Validation completed successfully |
1 |
Input file missing, invalid JSON, or validation failed |
Notes¶
validate-inventoryis a validation-only command- it does not enrich or rewrite the inventory
- it is typically run after
parse-inventoryand beforecreate-catalog
API reference¶
fontshow.cli.validate_inventory ¶
Fontshow validate-inventory CLI command.
This module implements the inventory validation stage of the Fontshow pipeline.
Responsibilities¶
- Validate inventory structure against the JSON schema.
- Run semantic validation checks on inventory metadata.
- Report validation results and warnings to the CLI.
Design principles¶
Validation logic itself resides in the inventory subsystem. This module only orchestrates the validation workflow and formats CLI output while delegating the actual checks to domain modules.
Architectural role¶
This module belongs to the CLI interface layer and implements the inventory validation entry point for the Fontshow CLI.
build_parser ¶
build_parser(parser: ArgumentParser) -> None
Register validate-inventory CLI arguments on a parser.
Parameters¶
parser : argparse.ArgumentParser Parser instance to configure for the validation command.
Returns¶
None
Notes¶
The parser is configured in place so the command can be registered
both under the top-level dispatcher and under a standalone
module-local __main__ block.
main ¶
main(args) -> int
Public CLI entrypoint for validate-inventory.
Parameters¶
args : argparse.Namespace Parsed CLI arguments containing the inventory path and common verbosity flags.
Returns¶
int
Process exit code returned by run(args).
Notes¶
Thin wrapper around run kept consistent with the other top-level
CLI modules so the command can be used uniformly through the
dispatcher and through module-local execution.
register_cli ¶
register_cli(parser: ArgumentParser) -> None
Register validate-inventory CLI arguments on an existing parser.
Parameters¶
parser : argparse.ArgumentParser Parser instance configured by the top-level dispatcher.
Returns¶
None
Notes¶
Used by the top-level Fontshow dispatcher to bind the
validate-inventory command to the shared validation entrypoint.
run ¶
run(args) -> int
CLI entry point for validating a Fontshow inventory against the JSON schema.
Parameters¶
args : argparse.Namespace Parsed CLI arguments containing the inventory path and common verbosity flags.
Returns¶
int Exit code: - 0 if validation succeeds - 1 if the file is missing, invalid JSON, schema validation fails, or semantic validation emits blocking errors.
Raises¶
OSError May propagate if the inventory file exists but cannot be read.
Notes¶
- Loads and normalizes enum values from the inventory.
- Performs JSON schema validation.
- Performs semantic validation of language codes.
- Emits CLI output according to severity and current CLI mode.
jsonschema.exceptions.ValidationErroris handled internally and converted into exit code1.