How to use the prompt.start function in prompt

To help you get started, we’ve selected a few prompt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ionic-team / ionic-cli / lib / ionic / login.js View on Github external
required: true
  }, {
    name: 'password',
    description: chalk.yellow.bold('Password:'),
    hidden: true,
    required: true
  }];

  // prompt for log
  log.info(chalk.bold.green('\nTo continue, please login to your Ionic account.'));
  log.info(chalk.bold('Don\'t have one? Create one at: ') + chalk.bold(appLibSettings.IONIC_DASH + '/signup') + '\n');

  prompt.override = argv;
  prompt.message = '';
  prompt.delimiter = '';
  prompt.start();

  prompt.get(schema, function(err, result) {
    if (err) {
      return q.reject('Error logging in: ' + err);
    }

    q.resolve({ email: result.email, password: result.password });
  });

  return q.promise;
}
github charlieschwabacher / gestalt / packages / gestalt-cli / src / migrate.js View on Github external
export default async function migrate({
  mutationsDirectory = 'mutations',
  mutationsGlob,
  url
}: {
  mutationsDirectory: string,
  mutationsGlob: string,
  url: string
}) {
  prompt.start();
  try {

    // we should be in a directory w/ schema.graphql and package.json
    invariant(
      fs.existsSync('schema.graphql') && fs.existsSync('package.json'),
      'gestalt migrate must be run from the root directory of a gestalt project'
    );

    const schemaText = fs.readFileSync('schema.graphql', 'utf8');
    const localPackage = JSON.parse(fs.readFileSync('package.json', 'utf8'));
    const localVersion = localPackage.dependencies['gestalt-server'];
    const cliVersion = require('../package.json').version;

    // version of gestalt-server in node modules should match the version of
    // gestalt-cli
    invariant(
github react-native-community / cli / packages / global-cli / index.js View on Github external
function createAfterConfirmation(name, options) {
  prompt.start();

  const property = {
    name: 'yesno',
    message: `Directory ${name} already exists. Continue?`,
    validator: /y[es]*|n[o]?/,
    warning: 'Must respond yes or no',
    default: 'no',
  };

  prompt.get(property, (err, result) => {
    if (result.yesno[0] === 'y') {
      createProject(name, options);
    } else {
      console.log('Project initialization canceled');
      process.exit();
    }
github vtex / toolbelt / src / lib / auth / login.js View on Github external
password: {
        hidden: true,
        message: 'password (typing will be hidden)',
        required: true
      }
    }
  };

  if (isUsingToken) {
    options.properties.password.hidden = false;
    options.properties.password.message = 'access token';
  }

  prompt.message = '> ';
  prompt.delimiter = '';
  prompt.start();

  prompt.get(options, (err, result) => {
    if (err) console.log('\nLogin failed. Please try again.');

    if (result && result.password) {
      return deferred.resolve(result.password);
    }

    return deferred.reject;
  });

  return deferred.promise;
}
github SwissRealCoin / src-token / tools / server / ganache.js View on Github external
const schema = {
            properties: {
                kill: {
                    pattern: /^(yes|no)$/,
                    message: 'Only yes or no allowed',
                    description: 'yes / no',
                    default: 'no',
                    required: true
                }
            }
        };

        log.warn(`Port ${PORT} already in use!`);
        log.warn(`Kill REALLY ALL node processes with open port ${PORT}?`);

        prompt.start();

        prompt.get(schema, (err, result) => {
            if (err) {
                log.error(err);
                process.exit(1);
            } else {
                if (result.kill === 'yes') {
                    sh.exec(`lsof -i tcp:${PORT} | grep node | awk '{print $2}' | xargs kill -9`, (code, stdout) => {
                        log.info(stdout);
                    });
                } else {
                    log.info('Command aborted');
                    process.exit(0);
                }
            }
        });
github bookercodes / communitycasts.co / admin.js View on Github external
function approve() {
  prompt.start();
  connection.queryAsync('SELECT * FROM screencasts WHERE status = \'pending\'').spread(function(screencasts) {
  var current = promise.resolve();
  promise.map(screencasts, function(screencast) {
    current = current.then(function() {
      console.log('Title: "' + screencast.title + '".');
      return prompt.getAsync(property);
    }).then(function(result) {
      if (result.approve === 'yes') {
        connection.queryAsync('UPDATE screencasts SET status = \'approved\' WHERE screencastId = ?', screencast.screencastId)
      } else {
        connection.queryAsync('UPDATE screencasts SET status = \'denied\' WHERE screencastId = ?', screencast.screencastId);
      }
    });
    return current;
  });
});
github ionic-team / ionic-cli / lib / ionic / docs.js View on Github external
var str = '';
        if (i > 0) {
          if (i === matches.length - 1)  {
            str = ' or ';
          } else {
            str = ', ';
          }
        }
        str += '(' + (i + 1 + '').cyan + ') ' + item.doc;
        return str;
      }).join('');
    } else {
      prompt.message += matches[0].doc;
    }
    prompt.message += '?';
    prompt.start();
    prompt.get({
      name: 'choice',
      default: matches.length === 1 ? 'yes' : '1'
    }, function(err, result) {
      if (err) {
        throw err;
      }
      var num;
      if (matches.length === 1) {
        if (result.choice.match(/^y/i, result.choice.trim())) {
          num = 1;
        }
      } else {
        num = parseInt(result.choice.trim());
      }
      if (!isNaN(num) && num > 0 && num <= matches.length) {
github indutny / vock / lib / vock / cli / main.js View on Github external
Cli.prototype.initPrompt = function initPrompt() {
  var self = this;

  prompt.start();
  prompt.message = '';
  prompt.delimiter = '';

  this.prompting = null;
};
github Widen / cloudfront-auth / build / build.js View on Github external
function googleConfiguration() {
  prompt.message = colors.blue(">>");
  prompt.start();
  prompt.get({
    properties: {
      CLIENT_ID: {
        message: colors.red("Client ID"),
        required: true,
        default: R.pathOr('', ['AUTH_REQUEST', 'client_id'], oldConfig)
      },
      CLIENT_SECRET: {
        message: colors.red("Client Secret"),
        required: true,
        default: R.pathOr('', ['TOKEN_REQUEST', 'client_secret'], oldConfig)
      },
      REDIRECT_URI: {
        message: colors.red("Redirect URI"),
        required: true,
        default: R.pathOr('', ['AUTH_REQUEST', 'redirect_uri'], oldConfig)
github ryanburgess / sassysass / lib / commands / page.js View on Github external
module.exports = function page() {
  prompt.message = 'SassySass'.magenta;
  prompt.delimiter = ' ';

  prompt.start();

  prompt.get({
    properties: {
      name: {
        description: 'What is the name of the page?',
        conform: function(fileName) {
          return !fs.existsSync(dir + '/' + filePath + '/' + fileName + '.scss');
        },
        message: 'Page already exists, please choose another name'
      },
      filePath: {
        description: 'Path to page directory?'
      },
      modules: {
        description: 'Add modules to page?'
      }