How to use the promptly.choose 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 superfly / fly / packages / core / src / cmd / apps.ts View on Github external
processResponse(res, async () => {
        const choices: any = {}
        // tslint:disable-next-line:forin
        for (const i in res.data.data) {
          choices[i] = res.data.data[i].id
        }

        let choiceText = ""
        for (const [i, slug] of Object.entries(choices)) {
          choiceText += `${i}) ${slug}\n`
        }

        const chose = await promptly.choose(
          `Select organization to move to:
${choiceText}
Enter a number:`,
          Object.keys(choices)
        )
        const orgSlug = choices[chose]
        console.log(`Moving app '${appName}' to organization '${orgSlug}'`)
        const resUpdate = await API.patch(`/api/v1/apps/${appName}`, {
          data: {
            attributes: {
              org_slug: orgSlug
            }
          }
        })

        processResponse(resUpdate, () => {
github bitpay / jsonPaymentProtocol / examples / bitcoinRpc.js View on Github external
// Must display network cost if provided, not doing so would be hiding costs
      const networkCost = minerFee / Math.pow(10, decimals);
      const usdCost = networkCost * getExchangeRate(chain, 'USD');
      console.log(`${index++}. ${chain} ${round(estimatedAmount * Math.pow(10, -decimals), decimals)} - (Network Cost: $${round(usdCost, 2)})`);
    }

    if (unavailable.length) {
      console.log(`There are ${unavailable.length} additional options that this wallet does not support or for which you do not have sufficient balance:`);
      for (let { chain, estimatedAmount, decimals } of unavailable) {
        console.log(`- ${chain} ${estimatedAmount * Math.pow(10, -decimals)}`);
      }
    }

    console.log('---');

    choice = await promptly.choose('What payment method would you like to use?', choices);
    choice = paymentOptions.responseData.paymentOptions[choice - 1];
  }

  let rpcConfig = config.rpcServers[choice.chain];
  rpcUrl = `http://${rpcConfig.ipAddress}:${rpcConfig.port}`;
  rpcUser = rpcConfig.username;
  rpcPass = rpcConfig.password;

  const { responseData: paymentRequest } = await client.selectPaymentOption(paymentOptions.requestUrl, choice.chain, choice.currency);

  /**
   * Wallet creates a transaction matching data in the instructions
   */

  // Format outputs as expected for bitcoin rpc client
  let outputObject = {};
github ZencashOfficial / nodetracker / setup.js View on Github external
.then((ipType) => {
      newcfg.ipv = ipType;
      return promptly.choose(
        `Region - ${serverInfo.regPrompt} ${msg5}`,
        regions,
        { default: region, validator: regValidator },
      );
    })
    .then((reg) => {
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 ZencashOfficial / nodetracker / setup.js View on Github external
getconfig((cfgAll) => {
    const msg1 = cfgAll.active && cfgAll.active !== 'testnet' ? ` (Existing: ${cfgAll.active}):` : ':';
    promptly
      .choose(
        `Enter the node type - secure or super ${msg1}`,
        ['secure', 'super'],
        { default: cfgAll.active, validator: typeValidator },
      )
      .then((ntype) => {
        newcfg.nodetype = ntype;
        let cfg = {};
        if (cfgAll.cfgOld) {
          newcfg.nodeid = cfgAll.cfgOld.nodeid;
          cfg = cfgAll.cfgOld;
        } else if (cfgAll.active === ntype) {
          cfg = cfgAll[ntype];
          if (cfg.nodeid) newcfg.nodeid = cfg.nodeid;
        }
        getSetupInfo(init.servers[ntype], (err, serverInfo) => {

promptly

Simple command line prompting utility

MIT
Latest version published 3 years ago

Package Health Score

74 / 100
Full package analysis