suppress spinner output with env var or flag
+32
Diff
round #0
+8
cli/index.ts
+8
cli/index.ts
···
143
143
}
144
144
145
145
program.name('wisp-cli').description('CLI for wisp.place - deploy static sites to the AT Protocol').version('1.1.1')
146
+
.option('-q, --quiet', 'Suppress progress output (also set via WISPCTL_NO_PROGRESS=1)')
146
147
147
148
// Deploy command (default)
148
149
program
···
557
558
}
558
559
})
559
560
561
+
// Set WISPCTL_NO_PROGRESS from --quiet flag before any command runs
562
+
program.hook('preAction', () => {
563
+
if (program.opts().quiet) {
564
+
process.env.WISPCTL_NO_PROGRESS = '1'
565
+
}
566
+
})
567
+
560
568
program.parse()
+24
cli/lib/progress.ts
+24
cli/lib/progress.ts
···
20
20
}
21
21
22
22
export function createSpinner(text: string): SpinnerLike {
23
+
// when no tty is attached or WISPCTL_NO_PROGRESS is set, return a silent spinner
24
+
if (!process.stdout.isTTY || process.env.WISPCTL_NO_PROGRESS === '1') {
25
+
let currentText = text
26
+
return {
27
+
get text() {
28
+
return currentText
29
+
},
30
+
set text(newText: string) {
31
+
currentText = newText
32
+
},
33
+
start() {
34
+
return this
35
+
},
36
+
succeed(message?: string) {
37
+
console.log(`✓ ${message ?? currentText}`)
38
+
return this
39
+
},
40
+
fail(message?: string) {
41
+
console.error(`✗ ${message ?? currentText}`)
42
+
return this
43
+
},
44
+
}
45
+
}
46
+
23
47
const s = spinner()
24
48
let currentText = text
25
49
let started = false