Server IP : 85.214.239.14 / Your IP : 18.189.180.234 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/3/task/3/root/proc/3/root/lib/node_modules/pm2/node_modules/enquirer/lib/prompts/ |
Upload File : |
'use strict'; const BooleanPrompt = require('../types/boolean'); class TogglePrompt extends BooleanPrompt { async initialize() { await super.initialize(); this.value = this.initial = !!this.options.initial; this.disabled = this.options.disabled || 'no'; this.enabled = this.options.enabled || 'yes'; await this.render(); } reset() { this.value = this.initial; this.render(); } delete() { this.alert(); } toggle() { this.value = !this.value; this.render(); } enable() { if (this.value === true) return this.alert(); this.value = true; this.render(); } disable() { if (this.value === false) return this.alert(); this.value = false; this.render(); } up() { this.toggle(); } down() { this.toggle(); } right() { this.toggle(); } left() { this.toggle(); } next() { this.toggle(); } prev() { this.toggle(); } dispatch(ch = '', key) { switch (ch.toLowerCase()) { case ' ': return this.toggle(); case '1': case 'y': case 't': return this.enable(); case '0': case 'n': case 'f': return this.disable(); default: { return this.alert(); } } } format() { let active = str => this.styles.primary.underline(str); let value = [ this.value ? this.disabled : active(this.disabled), this.value ? active(this.enabled) : this.enabled ]; return value.join(this.styles.muted(' / ')); } async render() { let { size } = this.state; let header = await this.header(); let prefix = await this.prefix(); let separator = await this.separator(); let message = await this.message(); let output = await this.format(); let help = (await this.error()) || (await this.hint()); let footer = await this.footer(); let prompt = [prefix, message, separator, output].join(' '); this.state.prompt = prompt; if (help && !prompt.includes(help)) prompt += ' ' + help; this.clear(size); this.write([header, prompt, footer].filter(Boolean).join('\n')); this.write(this.margin[2]); this.restore(); } } module.exports = TogglePrompt;