How to use the prompt.override 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 jplusplus / rentswatch-app / server / commands / stats.js View on Github external
#!/usr/bin/env node
'use strict';
// Load .env files (if needed)
require('../env')();

var fs = require('fs'),
     _ = require('lodash'),
   doc = require("../api/doc/doc.model"),
prompt = require('prompt'),
  argv = require('yargs').argv;

// Override prompt values with argv
prompt.override = argv
// Start the prompt
prompt.message = '';
prompt.delimiter = '';
prompt.start();

prompt.get([{
  name: 'output',
  type: 'string',
  default: 'stats.json',
  description: "Name of the ouput file:".magenta
}], function (err, params) {
  console.log("Extracting data...");
  // Extracting decades...
  doc.decades().then(function(decades) {
    var stats = { decades: decades };
    console.log("Calculating slope...");
github datproject / dat / src / commands / create.js View on Github external
properties: {
          title: {
            description: chalk.magenta('Title'),
            default: data.title || '',
            // pattern: /^[a-zA-Z\s\-]+$/,
            // message: 'Name must be only letters, spaces, or dashes',
            required: false
          },
          description: {
            description: chalk.magenta('Description'),
            default: data.description || ''
          }
        }
      }

      prompt.override = { title: opts.title, description: opts.description }
      prompt.message = '' // chalk.green('> ')
      // prompt.delimiter = ''
      prompt.start()
      prompt.get(schema, writeDatJson)

      function writeDatJson (err, results) {
        if (err) return exitErr(err) // prompt error
        if (!results.title && !results.description) return done()
        datjson.create(results, done)
      }
    }
github algolia / create-instantsearch-app / bin / create-instantsearch-app.js View on Github external
if(!targetFolderName) {
  console.log('The folder name for the new instantsearch project was not provided 😲'.red);
  program.help();
}

console.log(`Creating your new instantsearch app: ${targetFolderName.bold}`.green);

let prompts = [
  {name: 'appId', description: 'Application ID'.blue, required: true},
  {name: 'apiKey', description: 'Search API key'.blue, required: true},
  {name: 'indexName', description: 'Index name'.blue, required: true},
  {name: 'attributeName', description: 'Main searchable attribute'.blue, required: false},
];

prompt.message = '';
prompt.override = opts;

prompt.start();
prompt.get(prompts, function(err, config) {
  if(err) {
    console.log('\nProject creation cancelled 😢'.red);
    process.exit(0);
  } else {
    config.name = targetFolderName;
    config.targetFolderName = path.join(process.cwd(), targetFolderName);
    createProject(config);
    console.log('Project successfully created 🚀'.green.bold);
  }
})
github kacole2 / s3motion / s3motion.js View on Github external
.option('-L, --listClients', 'List clients')
	.option('-b, --listBuckets <--client>', 'List buckets for a specific client')
	.option('-N, --newBucket <--client --name>', 'Create a new bucket')
	.option('-l, --listObjects <--client --bucket>', 'List objects in a bucket')
	.option('-d, --downloadObject <--client --bucket --object --folder>', 'Download object(s) from bucket. Multiple object download supported by using commas and no spaces.')
	.option('-u, --uploadObject <--client --bucket --object --folder>', 'Upload object(s) to bucket. Multiple object upload supported by using commas and no spaces.')
	.option('-D, --deleteObject <--client --bucket --object>', 'Delete object(s) from bucket. Multiple deletion supported by using commas and no spaces.')
	.option('-c, --copyObject <--sourceClient --sourceBucket --object --destClient --destBucket --delete>', 'Copy object(s) between buckets. If --delete is Y, then source object is deleted after copy.')
	.option('-C, --copyBucket <--sourceClient --sourceBucket --destClient --destBucket>', 'Copy objects between buckets')
	.option('-R, --REST', 'Starts the REST based Web Service on port 8080')
	.parse(process.argv);

prompt.message = "";
prompt.delimiter = "";
prompt.colors = false;
prompt.override = optimist.argv;

if (program.newClient) {
	var questions = {
	    properties: {
		    	name: {
		    		description: 'Name: ',
		    		required: true
		    	},
		    	accessKeyId: {
		    		description: 'Access Key: ',
		    		required: true
		    	},
		    	secretAccessKey: {
		    		description: 'Secret Access Key: ',
		    		required: true
		    	},
github sebastian-software / edgestack / src / scripts / bootstrap.js View on Github external
export default async function bootstrap(args) {
  const argv = minimist(args)
  promptModule.override = argv

  const CURRENT_WORKING_DIR = process.cwd()
  const SRC_PATH = pathModule.join(CURRENT_WORKING_DIR, "src")

  const outputOkay = await checkOutputPath(SRC_PATH)
  if (!outputOkay)
    throw new Error(
      "Cannot savely write bootstrap files as a src " +
      "folder exists. Please make sure existing files are save."
    )

  try
  {
    const config = await askDefaultQuestions()
    await createBoilerplate(config, SRC_PATH)
    await createConfigFiles(CURRENT_WORKING_DIR)
github ionic-team / ionic-app-lib / lib / setup.js View on Github external
Setup.promptUserPromise = function promptUserPromise(schema) {
  var q = Q.defer();
  var prompt = require('prompt');

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

  prompt.get(schema, function(err, result) {
    if (err) {
      q.reject(err);
      return Utils.fail('Error getting Facebook app information: ' + err);
    }

    q.resolve(result);
  });

  return q.promise;
};
github flatiron / commandful / lib / commandful / controller.js View on Github external
controller.create = function (id, data, resource) {
  logger.warn('prompting user for data');
  if(typeof prompt.override.id !== 'undefined') {
    logger.info('define ' + prompt.override.id.magenta);
  } else {
    logger.info('define new ' + resource.lowerResource.magenta);
  }
  prompt.get(resource.schema, function (err, result) {
    if(err) {
      return;
    }
    logger.info('about to create ' + resource.lowerResource.magenta);
    cliff.putObject(result);
    resource.create(result, function(err, r){
      if(err) {
        logger.error(JSON.stringify(err))
        return;
      }
      logger.info('created new ' + resource.lowerResource.magenta + ' ' + r.id.grey)
    })
github bigcompany / big / node_modules / big-command / lib / command / controller.js View on Github external
controller.create = function (id, data, resource) {
  if(typeof prompt.override.id !== 'undefined') {
    logger.info('define ' + prompt.override.id.magenta);
  } else {
    logger.info('define new ' + resource.name.magenta);
  }
  logger.warn('prompting for data');
  prompt.get(resource.schema, function (err, result) {
    if(err) {
      return;
    }
    logger.info('about to create ' + resource.name.magenta);
    cliff.putObject(result);
    resource.create(result, function(err, r){
      if(err) {
        logger.error(JSON.stringify(err))
        return;
      }
      logger.info('created new ' + resource.name.magenta + ' ' + r.id.grey)
github datproject / dat / src / commands / auth / login.js View on Github external
email: {
        description: chalk.magenta('Email'),
        message: 'Email required',
        required: true
      },
      password: {
        description: chalk.magenta('Password'),
        message: 'Password required',
        required: true,
        hidden: true,
        replace: '*'
      }
    }
  }

  prompt.override = opts
  prompt.message = ''
  prompt.start()
  prompt.get(schema, function (err, results) {
    if (err) return exitErr(err)
    opts.server = results.server
    makeRequest(results)
  })

  function makeRequest (user) {
    var client = Registry(opts)
    client.login({
      email: user.email,
      password: user.password
    }, function (err, resp, body) {
      if (err && err.message) return exitErr(err.message)
      else if (err) return exitErr(err.toString())
github bigcompany / resources / node_modules / big-command / lib / command / controller.js View on Github external
controller.create = function (id, data, resource) {
  if(typeof prompt.override.id !== 'undefined') {
    logger.info('define ' + prompt.override.id.magenta);
  } else {
    logger.info('define new ' + resource.name.magenta);
  }
  logger.warn('prompting for data');
  prompt.get(resource.schema, function (err, result) {
    if(err) {
      return;
    }
    logger.info('about to create ' + resource.name.magenta);
    logger.put(result);
    resource.create(result, function(err, r){
      if(err) {
        logger.error(JSON.stringify(err))
        return;
      }
      logger.info('created new ' + resource.name.magenta + ' ' + r.id.grey)