How to use the promptly.confirm function in promptly

To help you get started, we’ve selected a few promptly 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 bitpay / jsonPaymentProtocol / examples / bitcoinRpc.js View on Github external
currency: choice.currency,
      unsignedTransactions: [{
        tx: fundedTx,
        // `vsize` for bitcoin core w/ segwit support, `size` for other clients
        weightedSize: decodedTx.vsize || decodedTx.size
      }]
    });
  } catch (e) {
    console.log('Error verifying payment');
    throw e;
  }

  // Display tx to user for confirmation
  console.log(JSON.stringify(decodedTx, null, 2));

  const signPayment = await promptly.confirm('Send this payment? (y/n)');
  if (!signPayment) {
    throw new Error('User aborted');
  }

  /**
   * Send signed transaction to server for actual payment
   */

  await sendPayment();
  await sendP2pPayment();

  async function sendPayment() {
    try {
      await client.sendSignedPayment({
        paymentUrl: paymentOptions.requestUrl,
        chain: choice.chain,
github bitpay / jsonPaymentProtocol / examples / bitcoinRpc.js View on Github external
async function sendPayment() {
    try {
      await client.sendSignedPayment({
        paymentUrl: paymentOptions.requestUrl,
        chain: choice.chain,
        currency: choice.currency,
        signedTransactions: [{
          tx: signedTx,
          // `vsize` for bitcoin core w/ segwit support, `size` for other clients
          weightedSize: decodedTx.vsize || decodedTx.size
        }]
      });
      console.log('Payment successfully sent via payment protocol');
    } catch (e) {
      console.log('Error sending payment', e);
      let confirm = promptly.confirm('Retry payment?', { default: false });
      if (confirm) {
        return await sendPayment();
      } else {
        throw e;
      }
    }
  }
github auth0 / wt-cli / bin / command_init.js View on Github external
function (cb) {
            if (!program.wt.config[options.profile])
                return cb();
            console.log('You already have the `' + options.profile + '` profile:');
            program.wt.print_profile(options.profile, program.wt.config[options.profile]);
            promptly.confirm('Do you want to override it? ', function (error, value) {
                if (error) return cb(error);
                if (!value) process.exit(1);
                cb();
            });
        },
        function (cb) {
github bitpay / jsonPaymentProtocol / examples / bitcoinRpc.js View on Github external
async function sendP2pPayment() {
    try {
      await broadcastP2P(signedTx);
    } catch (e) {
      console.log('Error broadcasting transaction to p2p network', e);
      let confirm = promptly.confirm('Retry broadcast?', { default: false });
      if (confirm) {
        return await sendPayment();
      } else {
        throw e;
      }
    }
  }
}
github divshot / divshot-cli / lib / commands / init.js View on Github external
overwrite: function (callback) {
          if (!cli.cwd.hasConfig()) return callback(null, true);
          
          promptly.confirm('Configuration file already exists. Overwrite?: (y/n)', function (err, overwrite) {
            if (overwrite) return callback(err, overwrite);
            process.exit(0);
          });
        },
github woocommerce / woocommerce-gutenberg-products-block / bin / changelog.js View on Github external
);
	console.log( '' );
	console.log(
		chalk.yellow(
			'Token scope will require read permissions on public_repo, admin:org, and user.'
		)
	);
	console.log( '' );
	console.log(
		chalk.yellow(
			'Export the token as variable called GH_API_TOKEN from your bash profile.'
		)
	);
	console.log( '' );

	const ready = await promptly.confirm( 'Are you ready to continue? ' );

	if ( ready ) {
		console.log( '' );
		console.log(
			chalk.yellow(
				'In order to generate the changelog, you will have to provide a version number to retrieve the PRs from.'
			)
		);
		console.log( '' );
		console.log(
			chalk.yellow( 'Write it as it appears in the milestones page: ' ) +
				'https://github.com/woocommerce/woocommerce-gutenberg-products-block/milestones'
		);
		console.log( '' );
		const version = await promptly.prompt( 'Version number: ' );
		console.log( '' );
github reindexio / reindex-api / utilities.js View on Github external
import promptly from 'promptly';
import { promisify } from 'bluebird';

export const choose = promisify(promptly.choose);
export const confirm = promisify(promptly.confirm);
export const prompt = promisify(promptly.prompt);
github divshot / divshot-cli / lib / commands / init.js View on Github external
createApp: function (callback) {
    promptly.confirm('Would you like to create a Divshot.io app from this app?: (y/n)', callback);
  }
};
github divshot / divshot-cli / lib / commands / rename.js View on Github external
.handler(function (name) {
      var self = this;
      var config = this.config;
      
      if (!name) return app.logger.error('You must provide a new name for your app');
      
      promptly.confirm('Are you sure you want to rename this app? It will be permanant and change the app\'s url. (y/n)', function (err, rename) {
        if (!rename) return;
        
        app.logger.writeln();
        app.logger.write('Renaming app to ' + app.format.bold(name) + ' ...');
        
        var stopLoading = app.loading();
        
        app.api.apps.id(self.config.name).rename(name, function (err, response) {
          stopLoading();
          
          if (response.error) return app.logger.error(response.error);
          if (response.statusCode && response.statusCode >= 400) return app.logger.error('Invalid request. Please try again.');
          
          app.cwd.setConfigValue('name', name);
          
          app.logger.write(app.format.blue(' done'));
github rutkai / Mjolnir-Authentication-Server / lib / cli / userHelper.js View on Github external
return new Promise(function (resolve, reject) {
        promptly.confirm(question, function (err, value) {
            if (value) {
                return resolve()
            }

            reject();
        });
    });
}

promptly

Simple command line prompting utility

MIT
Latest version published 4 years ago

Package Health Score

74 / 100
Full package analysis