constructor(options = {}) { super(); this.name = options.name; this.type = options.type; this.options = options; theme(this); timer(this); this.state = new State(this); this.initial = [options.initial, options.default].find(v => v != null); this.stdout = options.stdout || process.stdout; this.stdin = options.stdin || process.stdin; this.scale = options.scale || 1; this.term = this.options.term || process.env.TERM_PROGRAM; this.margin = margin(this.options.margin); this.setMaxListeners(0); setOptions(this); }
describe('options', () => { it('should accept `stdin` and `stdout` replacements', cb => { const stdin = process.stdin; const stdout = process.stdout; let count = 0;
/** * Prompt input with the given `msg` and callback `fn`. * * @param {String} msg * @param {Function} fn */ export function prompt(msg: string, fn: Function) { if (' ' === msg[msg.length - 1]) { process.stdout.write(msg); } else { console.log(msg); } process.stdin.setEncoding('ascii'); process.stdin.once('data', function (data) { fn(data); }).resume(); }
/** * Init application at the given directory `path`. * * @param {String} path */ function init(path: string) { console.log(INIT_PROJ_NOTICE); connectorType(function (type: string) { let empty = emptyDirectory(path); if (empty) { process.stdin.destroy(); console.log('start createApplication'); createApplicationAt(path, type); } else { confirm('Destination is not empty, continue? (y/n) [no] ', function (force: boolean) { process.stdin.destroy(); if (force) { createApplicationAt(path, type); } else { abort(('Fail to init a project' as any).red); } }); } }); }
function startCli() { let rl = readline.createInterface(process.stdin, process.stdout, completer); let PROMPT = username + consts.PROMPT + context + '>'; rl.setPrompt(PROMPT);
function interactive(bot) { const sessionId = options.session || 'INTERACTIVE'; const rl = readline.createInterface({ input: process.stdin, output: process.stdout, });