Skip to content

feat(cli): add --no-color flag and honor NO_COLOR (#24) - #31

Merged
pachara-n merged 2 commits into
pachara-n:mainfrom
ak-bharadwaj:feat/no-color
Nov 3, 2026
Merged

pachara-n merged 2 commits into
pachara-n:mainfrom
ak-bharadwaj:feat/no-color

Conversation

@ak-bharadwaj

@ak-bharadwaj ak-bharadwaj commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part of #24 (starter scope).

Adds --no-color CLI option via Commander and honors the standard NO_COLOR environment variable (per no-color.org):

  • Added --no-color option to Commander.
  • Added useColor check evaluating options.color !== false && !("NO_COLOR" in process.env && process.env.NO_COLOR !== "").
  • Routed text output symbols through style() helper returning plain text when color is disabled.
  • Added integration tests in test/integration.test.ts verifying that ANSI escape sequences are omitted when NO_COLOR=1 or --no-color is set, and preserved by default.

@pachara-n pachara-n left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ak-bharadwaj, this is close! The flag, NO_COLOR handling (non-empty per no-color.org) and the tests look good. Two things before I merge:

  1. Color when output isn't a terminal. The PR now colors ✔/✖ by default, including when stdout is piped (skills-lint > report.txt would contain \x1b[31m). Could you also require process.stdout.isTTY in useColor? The "includes ANSI color sequences by default" test runs through spawnSync, which isn't a TTY, so it would flip to asserting that piped output has no escape codes.
  2. Scope: this covers the starter scope only, so I've changed Closes #24 to Part of #24 to keep the rest of the issue open.

@ak-bharadwaj

Copy link
Copy Markdown
Contributor Author

Thanks @pachara-n!

Updated in commit b94de77:

  1. Added Boolean(process.stdout.isTTY) to useColor in src/cli.ts: Piped/redirected output (skills-lint > report.txt) now defaults to plain text without ANSI escape sequences.
  2. Updated integration test: Adjusted the test in test/integration.test.ts to assert that piped output through spawnSync omits ANSI escape codes by default.

All 41 unit and integration tests are passing cleanly. Ready for merge!

@pachara-n

Copy link
Copy Markdown
Owner

Thanks @ak-bharadwaj — merging. The flag, the NO_COLOR handling and the scope are right. One note for next time: per CONTRIBUTING, a test should fail without the change; these three check that output has no escape codes, which was already true before this PR. I'll add tests for the enabled-color path separately (tracked in #24).

@pachara-n
pachara-n merged commit 900a0ab into pachara-n:main Nov 3, 2026
3 checks passed
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.

2 participants