Skip to content

Commit 022d909

Browse files
committed
Add --no-color
1 parent 16589a9 commit 022d909

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/language/cli/output.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import either, { type Either } from '@matt.kantor/either'
2+
import kleur from 'kleur'
23
import { parseArgs } from 'node:util'
34
import { type SyntaxTree } from '../parsing/syntax-tree.js'
45
import {
@@ -17,10 +18,18 @@ export const handleOutput = async (
1718
args: process.argv.slice(2), // remove `execPath` and `filename`
1819
strict: false,
1920
options: {
21+
'no-color': { type: 'boolean' },
2022
'output-format': { type: 'string' },
2123
},
2224
})
2325

26+
const noColorArg = args.values['no-color'] ?? false
27+
if (typeof noColorArg !== 'boolean') {
28+
throw new Error('Unsupported value for --no-color')
29+
} else if (noColorArg === true) {
30+
kleur.enabled = false
31+
}
32+
2433
const outputFormatArg = args.values['output-format']
2534
let notation: Notation
2635
if (outputFormatArg === undefined) {

0 commit comments

Comments
 (0)