How to use the cli-ux.cli.prompt function in cli-ux

To help you get started, we’ve selected a few cli-ux 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 ItalyPaleAle / hereditas / cli / commands / build.js View on Github external
// Make sure that we have an Auth0 client id
        const clientId = config.get('auth0.hereditasClientId')
        if (!clientId) {
            this.error('The Hereditas application hasn\'t been configured on Auth0 yet. Please run `hereditas auth0:sync` first')
            return this.exit(1)
        }

        // Check if we have a passphrase passed as environmental variable (useful for development only)
        let passphrase
        if (process.env.HEREDITAS_PASSPHRASE) {
            passphrase = process.env.HEREDITAS_PASSPHRASE
            this.warn('Passphrase set through the HEREDITAS_PASSPHRASE environmental variable; this should be used for development only')
        }
        else {
            // Ask for the user passphrase
            passphrase = await cli.prompt('User passphrase', {type: 'mask'})
        }
        if (!passphrase || passphrase.length < 8) {
            this.error('Passphrase needs to be at least 8 characters long')
            return this.exit(1)
        }

        // Timer
        const startTime = Date.now()

        // Build the project
        const builder = new Builder(passphrase, config)
        await builder.build()

        // Done!
        const duration = (Date.now() - startTime) / 1000
github 1MB / 1mb-cli / src / commands / deploy.js View on Github external
async run() {
        const {flags} = this.parse(DeployCommand)
        const self = this

        if (flags.clearcreds === true) {
            conf.clear()
        }

        let username = conf.get('username')
        if (typeof username === 'undefined') {
            username = await cli.prompt('What is your 1mbsite username?')
        }

        let key = conf.get('key')
        if (typeof key === 'undefined') {
            key = await cli.prompt('What is your 1mbsite api key?', {
                type: 'mask'
            })

            if (await cli.confirm('Would you like to save these credentials for future deployments?')) {
                conf.set('key', key)
                conf.set('username', username)
                this.log('Saved credentials!')
            }
        }

        if(flags.clear_files || flags.vuejs || flags.reactjs) {
            // clear all active resources
            request.post('https://api.1mb.site', {
                form: {
                    action: 'resources',
                    site: username,
github SakkuCloud / sakku-cli / src / commands / exec.ts View on Github external
async run() {
    const { args, flags } = this.parse(Exec);
    let appId: string;

    if (args.app)
      appId = args.app;
    else
      appId = await cli.prompt('enter app id/name');

    let data;

    try {
      // @ts-ignore
      if (!isNaN(appId)) {
        data = await appService.get(this, appId)
          .then(value => value.data);
      }
      else {
        data = await appService.getByName(this, appId)
          .then(value => value.data);
      }

      if (data.error) {
        this.log('error code:', data.code, data.message);
github SakkuCloud / sakku-cli / old / app.ts View on Github external
break
            case 'rm':
                var appId = await cli.prompt('Enter your app id',{required:true})
                var confimation = await cli.confirm('are you really sure to remove?')
                if (confimation){
                    await cli.action.start('please wait...')
                    await cli.wait(2000)
                    cli.action.stop('removed!')
                    this.log('your app is not any more exist in this universe!')
                }else {
                    this.log('notting happend!')
                }
                break
            case 'scale':
                var appId = await cli.prompt('Enter your app id',{required:true})
                var appId = await cli.prompt('Enter your app scale',{required:true})
                
        }
    }
}
github superfly / fly / packages / cli / src / commands / login.ts View on Github external
public async run() {
    const email = await cli.prompt("email")
    const password = await cli.prompt("password", { type: "hide" })
    const otp = await cli.prompt("2FA code (if any)", { default: "n/a", required: false })
    const res = await axios.post(`${baseURL}/api/v1/sessions`, {
      data: { attributes: { email, password, otp } }
    })

    processResponse(this, res, () => {
      const access_token = res.data.data.attributes.access_token
      storeCredentials({ access_token })
      storeNetrcCredentials("git.fly.io", access_token)
      console.log("Wrote credentials at:", credentialsPath())
    })
  }
}
github idexio / IDEXd / aurad-cli / src / commands / config.js View on Github external
async run() {
    await docker.ensureDirs();
    const {flags} = this.parse(ConfigCommand);
    console.log(messages.WALLET_EXPLAINER);
 
    const containers = await docker.getRunningContainerIds();
    if (containers['idexd']) {
      console.log(`Error: idexd is running, please run 'idex stop' before updating your config`);
      return;
    }
    if (containers['aurad']) {
      console.log(`Error: an older version of aurad is running, please run 'idex stop' before updating your config`);
      return;
    }
   
    let coldWallet = await cli.prompt('    ' + chalk.blue.bgWhite(messages.WALLET_PROMPT));      
    let challenge;
    try {
      challenge = await getChallenge(coldWallet);
    } catch(status) {
      if (status == 403) {
        console.log(`    ${chalk.red('ERROR')}: Your cold wallet is not qualified for staking`);
      } else {
        console.log(`    ${chalk.red('ERROR')}: Unknown error getting signing challenge`);
      }
      return;   
    }
    
    const { balance } = await getBalance(coldWallet);
    
    console.log('');
github superfly / fly / packages / cli / src / commands / apps / delete.ts View on Github external
public async run() {
    const { flags } = this.parse(Delete)

    const API = this.apiClient(flags)
    const appName = this.getAppName(flags)

    this.log(`Are you sure you want to delete '${appName}'?`)

    let tries = 1

    while (true) {
      const confirmation = await cli.prompt("Type the app's name to confirm", {})

      if (confirmation === appName) {
        break
      }

      if (++tries > 3) {
        this.error("too many attempts, not continuing", { exit: 1 })
        return
      }

      this.warn("incorrect, try again")
    }

    const res = await API.delete(`/api/v1/apps/${appName}`)
    processResponse(this, res, () => {
      console.log("App deleted.")
github fauna / fauna-shell / src / commands / cloud-login.js View on Github external
async function cloudStrategy() {
  const email = await cli.prompt('Email', {timeout: 120000})
  const password = await cli.prompt('Password', {type: 'hide', timeout: 120000})

  const formData = {
    email: email,
    password: password,
    session: 'Fauna Shell - ' + os.hostname(),
  }

  let options = {
    method: 'POST',
    uri: SHELL_LOGIN_URL,
    form: formData,
    resolveWithFullResponse: true,
  }

  return rp(options)
github SakkuCloud / sakku-cli / src / commands / app / deploy.ts View on Github external
.then(function (result) {
                return cli.prompt(messages.enter_local_image_tag, { required: false })
              })
              .then(function (param) {
github heroku / cli / packages / auth / src / commands / labs / disable.ts View on Github external
async prompt(out: any, app: string): Promise {
      out.warn('Insecure Action')
      let name = await cli.prompt(`You are enabling an older security protocol, TLS 1.0, which some organizations may not deem secure.
To proceed, type ${app} or re-run this command with --confirm ${app}`)
      return name
    }
  }