Skip to content

feat(cli): add --multi-output option for separate grammar compilation#651

Merged
hildjj merged 2 commits intopeggyjs:mainfrom
knoan:feature/gh650
Dec 14, 2025
Merged

feat(cli): add --multi-output option for separate grammar compilation#651
hildjj merged 2 commits intopeggyjs:mainfrom
knoan:feature/gh650

Conversation

@knoan
Copy link
Contributor

@knoan knoan commented Dec 12, 2025

Summary

Add --multi-output <dir> CLI option that compiles multiple input grammars to separate output files instead of merging them into a single parser.

Changes

  • Add --multi-output <dir> option to CLI with .conflicts("output")
  • Add validation in opts.js (cannot use with stdin)
  • Implement multi-output branch in run() method
  • Add 5 tests for the new feature
  • Update documentation and changelog

Usage

peggy --multi-output ./out/ grammar1.peggy grammar2.peggy
# produces: ./out/grammar1.js, ./out/grammar2.js

peggy --multi-output ./out/ --dts --source-map -- a.peggy b.peggy
# produces: ./out/a.js, ./out/a.d.ts, ./out/a.js.map, ./out/b.js, ./out/b.d.ts, ./out/b.js.map

Test plan

  • Unit tests added (5 tests)
  • Manual testing completed
  • Lint passes
  • All 53 CLI tests pass

Closes #650

Add --multi-output <dir> CLI option that compiles multiple input grammars
to separate output files instead of merging them into a single parser.

- Conflicts with --output (mutually exclusive)
- Cannot be used with stdin input
- Works with --dts and --source-map (generates per-file)

Closes peggyjs#650
@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.48%. Comparing base (f4e5c5a) to head (ddcb829).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #651   +/-   ##
=======================================
  Coverage   99.48%   99.48%           
=======================================
  Files          34       34           
  Lines        4283     4313   +30     
=======================================
+ Hits         4261     4291   +30     
  Misses         22       22           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hildjj
Copy link
Contributor

hildjj commented Dec 12, 2025

Will do a full review tomorrow, probably. In the meantime, it should be relatively easy to add coverage for the two lines that codecov flagged.

@knoan
Copy link
Contributor Author

knoan commented Dec 14, 2025

Will do a full review tomorrow, probably. In the meantime, it should be relatively easy to add coverage for the two lines that codecov flagged.

Done

@hildjj
Copy link
Contributor

hildjj commented Dec 14, 2025

LGTM. Fantastic patch, thank you very much.

@hildjj hildjj merged commit ddbc01d into peggyjs:main Dec 14, 2025
10 checks passed
@hildjj
Copy link
Contributor

hildjj commented Dec 14, 2025

To be release in Peggy 5.1, hopefully this week.

@hildjj hildjj mentioned this pull request Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Support output directory for separate grammar compilation

3 participants