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); }
constructor(prompt) { let options = prompt.options; define(this, '_prompt', prompt); this.type = prompt.type; this.name = prompt.name; this.message = ''; this.header = ''; this.footer = ''; this.error = ''; this.hint = ''; this.input = ''; this.cursor = 0; this.index = 0; this.lines = 0; this.tick = 0; this.prompt = ''; this.buffer = ''; this.width = width(options.stdout || process.stdout); Object.assign(this, options); this.name = this.name || this.message; this.message = this.message || this.name; this.symbols = prompt.symbols; this.styles = prompt.styles; this.required = new Set(); this.cancelled = false; this.submitted = false; }
describe('options', () => { it('should accept `stdin` and `stdout` replacements', cb => { const stdin = process.stdin; const stdout = process.stdout; let count = 0; let error;
export function log(str: string) { process.stdout.write(str + '\n'); }
/** * 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(); }
function startCli() { let rl = readline.createInterface(process.stdin, process.stdout, completer); let PROMPT = username + consts.PROMPT + context + '>'; rl.setPrompt(PROMPT);
/** * Writes an inline message to standard output. * * @private * @param {string} [text=''] The text to log. */ function logInline(text) { var blankLine = _.repeat(' ', _.size(prevLine)); prevLine = text = _.truncate(text, { 'length': 40 }); process.stdout.write(text + blankLine.slice(text.length) + '\r'); }
function clog(string_or_err) //log to console/command prompt { if (!devTools.enableConsoleLog) return; if (string_or_err && string_or_err.hasOwnProperty('stack')) string_or_err = string_or_err.stack; if (!isNull(string_or_err)) process.stdout.write(string_or_err); }
const rl = readline.createInterface({ input: process.stdin, output: process.stdout, });
process.stdout.write(Buffer.from(response.serializeBinary()));