configure-output.js
This file
Path
examples/configure-output.js
29 lines · 766 bytes · JavaScript
Last changed by
Use standard import in examples (#2168)John Geebefore adoption41b12cf
History of this fileTake it
The walk stopped after 200 commits: lines older than 0b0fbbe point at it.
Use standard import in examples (#2168)John Geebefore adoption41b12cf
line 1why, one step back1const commander = require('commander');Update dependencies (#1524)John Geebefore adoption0b0fbbe
lines 2–25why, 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}89program10 .configureOutput({11 // Visibly override write routines as example!12 writeOut: (str) => process.stdout.write(`[OUT] ${str}`),13 writeErr: (str) => process.stdout.write(`[ERR] ${str}`),14 // Output errors in red.15 outputError: (str, write) => write(errorColor(str))16 });1718program19 .version('1.2.3')20 .option('-c, --compress')21 .command('sub-command');2223program.parse();2425// Try the following:Make examples more consistent with "Try the following" (#1629)John Geebefore adoption2cc3a36
lines 26–29why, one step back26// node configure-output.js --version27// node configure-output.js --unknown28// node configure-output.js --help29// node configure-output.js