Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

fix(cli): honor no-color before rendering help and version (#4248)

他们都不玩了64d00f4ab22f
diff --git a/v3/@claude-flow/cli/__tests__/cli.test.ts b/v3/@claude-flow/cli/__tests__/cli.test.ts
index 87c21943f7..3b56503dba 100644
--- a/v3/@claude-flow/cli/__tests__/cli.test.ts
+++ b/v3/@claude-flow/cli/__tests__/cli.test.ts
@@ -384,9 +384,20 @@ describe('CLI', () => {
});
it('should disable color with --no-color', async () => {
- await cli.run(['--no-color', '--help']);
- // Color should be disabled - check output formatter state
- expect(cli['output']['colorEnabled']).toBe(false);
+ const originalColorEnabled = cli['output']['colorEnabled'];
+ try {
+ for (const flag of ['--help', '--version', '-V']) {
+ // CI starts without a TTY; explicitly enable colors so this cannot
+ // pass merely because the formatter already has colors disabled.
+ cli['output'].setColorEnabled(true);
+ consoleOutput.length = 0;
+ await cli.run(['--no-color', flag]);
+ expect(cli['output']['colorEnabled']).toBe(false);
+ expect(consoleOutput.join('')).not.toMatch(/\u001b\[/);
+ }
+ } finally {
+ cli['output'].setColorEnabled(originalColorEnabled);
+ }
});
});
diff --git a/v3/@claude-flow/cli/src/index.ts b/v3/@claude-flow/cli/src/index.ts
index a417b95c1f..dbdf522121 100644
--- a/v3/@claude-flow/cli/src/index.ts
+++ b/v3/@claude-flow/cli/src/index.ts
@@ -108,15 +108,15 @@ export class CLI {
const { command: commandPath, flags, positional } = parseResult;
// Handle global flags
+ if (flags.noColor || flags.color === false) {
+ this.output.setColorEnabled(false);
+ }
+
if (flags.version || flags.V) {
this.showVersion();
return;
}
- if (flags.noColor) {
- this.output.setColorEnabled(false);
- }
-
// Set verbosity level based on flags
if (flags.quiet) {
this.output.setVerbosity('quiet');