Skip to content

feat(cli): enforce positional argument counts, canonical parser, and --file flag - #138

Merged
udoyechinenyevictoria merged 2 commits into
Esureorg:mainfrom
software321dev:feat/cli-args-parsing-file
Oct 21, 2026
Merged

udoyechinenyevictoria merged 2 commits into
Esureorg:mainfrom
software321dev:feat/cli-args-parsing-file

Conversation

@software321dev

Copy link
Copy Markdown
Contributor

Summary of Changes

This PR addresses issues #50, #51, #52, and #53 with the following improvements to @esure/cli:

  1. Enforce Command-Specific Argument Counts (CLI: enforce positional argument counts for each command #50):

    • list strictly rejects any positional arguments and displays usage.
    • validate requires exactly one file path target, rejecting both missing and extra arguments.
    • run requires exactly one target (either via positional argument or --file), rejecting missing or extraneous arguments.
    • Paths containing spaces work seamlessly when passed as a single quoted argument.
  2. Use Canonical Scenario Parser (CLI: use the canonical scenario parser for local files #51):

    • Local scenario file parsing is routed through the canonical parseScenario from @esure/backend/src/scenario-loader.js.
    • Before reading an oversized file into memory, stat enforces SCENARIO_LIMITS.definitionBytes.
    • Applies backend parser options (disallowing duplicate keys in YAML, disallowing anchors, strict schema validations).
    • Validation failures retain actionable error issues without dumping file contents.
  3. Case-Insensitive File Extensions (CLI: accept case-insensitive scenario file extensions #52):

    • Uses path.extname(filePath).toLowerCase() to normalize file extensions.
    • Accepts .json, .JSON, .yaml, .YAML, .yml, and any mixed-case variations.
    • Ensures directory names containing dots (e.g. dir.json/scenario.yaml) do not influence format detection.
    • Leaves the original file path intact for resolution and file operations.
  4. Explicit --file Selector (CLI: add an explicit --file selector for run targets #53):

    • Added --file <path> option to esure run to explicitly select a local scenario file without heuristics.
    • Mutual exclusivity enforced: passing both --file and a positional target fails with a descriptive error.
    • Nonexistent files produce a clear path-related error message (Scenario file not found: ...).
    • Updated CLI --help text to document the --file flag and usage examples.
  5. Testing:

    • Added comprehensive unit tests covering all positive and negative cases for argument counts, file extensions, oversized files, duplicate YAML keys, and --file resolution.
    • All 60 test cases pass.

Closes #50
Closes #51
Closes #52
Closes #53

…--file flag

- Enforce argument counts: reject positionals for list, require 1 target for validate and run
- Use canonical parseScenario and check definition byte limits via stat before reading
- Normalize scenario file extensions with extname for case-insensitivity (.json, .yaml, .yml)
- Add explicit --file flag for run command with mutual exclusivity against positional targets
- Add comprehensive unit test coverage for argument parsing, extensions, and limits

Closes Esureorg#50, Esureorg#51, Esureorg#52, Esureorg#53
@drips-wave

drips-wave Bot commented Oct 16, 2026

Copy link
Copy Markdown

@software321dev 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

@vercel

vercel Bot commented Oct 16, 2026

Copy link
Copy Markdown

@software321dev 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.

@udoyechinenyevictoria

Copy link
Copy Markdown
Collaborator

resolve conflict please

@udoyechinenyevictoria
udoyechinenyevictoria merged commit 430d652 into Esureorg:main Oct 21, 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