Skip to content

feat(cli): add scenario inspection, stdin validation, directory validation, and list filtering - #133

Merged
udoyechinenyevictoria merged 2 commits into
Esureorg:mainfrom
serverlessdomain-hash:feat/cli-show-filter-validate
Oct 22, 2026
Merged

udoyechinenyevictoria merged 2 commits into
Esureorg:mainfrom
serverlessdomain-hash:feat/cli-show-filter-validate

Conversation

@serverlessdomain-hash

Copy link
Copy Markdown
Contributor

Outcome

This pull request enhances the esure CLI toolkit with essential scenario inspection, offline directory validation, stdin pipeline integration, and deterministic catalogue filtering without network overhead, solving issues #61, #63, #64, and #65.

Closes #61
Closes #63
Closes #64
Closes #65

Changes

1. Show command for bundled scenarios (esure show <scenario-id>) - #61

  • Added show <scenario-id> command to inspect scenario definitions offline via the local scenario registry without triggering network calls or gateway construction.
  • Supports both human-readable and JSON output modes (--output json).
  • Retains decimal amounts as strings in JSON output envelopes.
  • Returns a clear nonzero error code (1) when an unknown scenario ID is requested.
  • Documented show with usage examples in CLI --help and root README.md.

2. Standard input scenario validation (esure validate --stdin --format <format>) - #63

  • Added --stdin support to the validate command for reading scenario definitions from pipes and CI streams.
  • Requires explicit input --format (json or yaml) to prevent ambiguous parsing.
  • Bounded buffering enforces the maximum shared byte limit (SCENARIO_LIMITS.definitionBytes = 16,384 bytes), throwing validation errors immediately if exceeded.
  • Detects interactive terminals (process.stdin.isTTY) and fails fast with a helpful error message rather than hanging silently.
  • Formats errors using the standard validation envelope { valid: false, error: ... } when --output json is requested.

3. Offline directory validation (esure validate-directory <dir>) - #64

  • Added non-recursive validate-directory <dir> command to validate collections of .json, .yaml, and .yml scenario files in a single invocation.
  • Processes supported files in deterministic lexicographical order (localeCompare).
  • Enforces directory size limits (maxFilesPerDirectory = 100) and individual definition size limits (SCENARIO_LIMITS.definitionBytes).
  • Collects and reports issues across all files rather than halting at the first failure.
  • Detects scenario ID collisions across files and flags duplicates.
  • Returns exit code 1 if any file fails validation or if duplicate IDs are present; returns 0 when all scenarios pass.
  • Supports structured summary JSON (summary: { total, passed, failed }) and human-readable reporting.

4. Deterministic filtering and sorting for list command - #65

  • Added case-insensitive substring searching via --search <term> across scenario id, name, and description without regex execution.
  • Trims whitespace from search terms and returns an empty collection cleanly when zero scenarios match.
  • Added explicit ID sorting with --sort id.
  • Ensures output parity between human-readable text and JSON output modes.
  • Guarantees search and sort filtering operates on cloned catalog arrays with zero side-effects on the registry.

5. Documentation & Test Suite

  • Updated root README.md CLI usage section with minimal examples for show, list --search, validate --stdin, and validate-directory.
  • Added comprehensive unit tests in esure-cli/test/cli.test.ts covering valid inputs, invalid schemas, error handling, bounds checking, empty inputs, duplicate detection, and CLI help/options parity (43 tests passing).

Verification

  • Repository check command passes (npm run typecheck, npm run build, npm test in esure-cli and npm test in esure-backend)
  • Tests cover the changed behavior (43 unit tests in esure-cli/test/cli.test.ts)
  • Documentation is updated where needed (README.md and CLI --help)
  • No secrets, .env files, or generated account keys are included
  • Visual changes include screenshots and accessibility checks (N/A - CLI only)

Scope

…and list filtering

- Add 'show <scenario-id>' command to inspect bundled scenarios offline
- Add '--search' and '--sort id' flags to 'list' command for deterministic filtering
- Add '--stdin' option with required '--format' to 'validate' command with byte bounds
- Add 'validate-directory <dir>' command with per-file summaries and duplicate detection
- Document new CLI commands and options in README.md and '--help'
- Add comprehensive test coverage in esure-cli/test/cli.test.ts

Closes Esureorg#61, Closes Esureorg#63, Closes Esureorg#64, Closes Esureorg#65
@vercel

vercel Bot commented Oct 16, 2026

Copy link
Copy Markdown

@serverlessdomain-hash is attempting to deploy a commit to the Favour Chigozirim's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Oct 22, 2026

Copy link
Copy Markdown

@serverlessdomain-hash Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@udoyechinenyevictoria
udoyechinenyevictoria merged commit b3a48bf into Esureorg:main Oct 22, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants