configure-output.js
This file
Path
examples/configure-output.js
25 lines · 743 bytes · JavaScript
Last changed by
Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
History of this fileTake it
The walk stopped after 200 commits: lines older than 3103c6b point at it.
Use standard import in examples (#2168)John Geebefore adoption41b12cf
line 1why, one step back1const commander = require('commander');Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 2–8why, one step back2const program = new commander.Command();34function errorColor(str) {5 // Add ANSI escape codes to display text in red.6 return `\x1b[31m${str}\x1b[0m`;7}8Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 9–15why, one step back9program.configureOutput({10 // Visibly override write routines as example!11 writeOut: (str) => process.stdout.write(`[OUT] ${str}`),12 writeErr: (str) => process.stdout.write(`[ERR] ${str}`),13 // Output errors in red.14 outputError: (str, write) => write(errorColor(str)),15});Add more tests for implies (#1730)John Geebefore adoption3103c6b
line 16why, one step back16Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 17why, one step back17program.version('1.2.3').option('-c, --compress').command('sub-command');Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 18–25why, one step back1819program.parse();2021// Try the following:22// node configure-output.js --version23// node configure-output.js --unknown24// node configure-output.js --help25// node configure-output.js