Skip to content

fix(cli): name .mts, DESIGN.md and inspect --format in --help, and reject an unknown inspect format - #261

Merged
dgesteves merged 1 commit into
dgesteves:mainfrom
kasettadoo-sys:fix/cli-help-and-inspect-format
Oct 30, 2026
Merged

dgesteves merged 1 commit into
dgesteves:mainfrom
kasettadoo-sys:fix/cli-help-and-inspect-format

Conversation

@kasettadoo-sys

Copy link
Copy Markdown
Contributor

Closes #222.

What

Three help lines were behind the code, and inspect accepted any --format.

--help

Line Before After
--config onsystem.config.{json,ts,mjs,js} onsystem.config.{json,ts,mts,js,mjs}
--tokens Token file (DTCG .json or CSS) Token file (DTCG .json, CSS or DESIGN.md)
--format check: and export: only inspect: pretty | json (default: pretty) added

All three were already right in docs/cli.md; --help was the one lagging.

inspect --format

inspect only looked for json, so --format xml (or a typo) printed the pretty output and exited 0, where check and export exit 2. A script that asked for JSON and got text read it as a design system with nothing in it. It now exits 2 with one line in check's style:

$ onsystem inspect --format xml
inspect: unknown --format "xml" (pretty, json)

The check sits at the top of inspect(), before loadTarget, as the issue's hint suggests, so the monorepo root that inspectWorkspace handles is covered by the same four lines.

Tests

  • test/cli.test.ts: --help names every extension in CONFIG_FILES (compared as a set, parsed out of the brace list, so js cannot pass by being a substring of json); the usage-error test covers inspect --format xml; and a new case asserts exit 2, the one-line message and empty stdout both in a project and at a monorepo root (pnpm-workspace.yaml + appIn). Reverted against the fix, all three fail.
  • test/cli-docs.test.ts: --format's commands are now check, inspect, export. With inspect named in --help, BEYOND_HELP — the escape hatch for an option --help does not name for a command — had no entries left, so it and the assertion it skipped are gone; that assertion now runs for the inspect --format row. The test that runs inspect --format json keeps doing so, under a title that no longer says --help omits it.

Docs

docs/cli.md needed one row: inspect's --format now names pretty as the default alongside json and says another value exits 2, since that behaviour is new. docs/configuration.md is untouched, as the issue asks.

Checks

pnpm lint, pnpm format:check, pnpm typecheck, pnpm build, pnpm smoke and pnpm test (1428 passed, 3 skipped) all pass locally. pnpm build left schema.json unchanged. Patch changeset included.

…ject an unknown inspect format

`--help` was behind the code in three places: `--config` left out
onsystem.config.mts, `--tokens` left out a DESIGN.md, and `--format`
listed values for check and export only, though `inspect --format json`
works and docs/cli.md documents it.

`inspect` also took any format: `--format xml` printed the pretty output
and exited 0, where check and export exit 2. It is checked before the
project is loaded, so a monorepo root is covered too.

With inspect named in `--help`, no option is beyond it any more, so
BEYOND_HELP and the assertion it skipped are gone from the docs test.

Closes dgesteves#222
@dgesteves
dgesteves merged commit 452e5c0 into dgesteves:main Oct 30, 2026
15 checks passed
@dgesteves-release dgesteves-release Bot mentioned this pull request Oct 30, 2026
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.

--help leaves out .mts configs, DESIGN.md and inspect --format json

2 participants