How to use the cli-ux.action 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 smartcontractkit / chainlink / belt / src / commands / deploy.ts View on Github external
// Transforms string arrays to arrays
    const parsedInputs = parseArrayInputs(inputs)

    // Intialize ethers contract factory
    const factory = new ethers.ContractFactory(
      abi['compilerOutput']['abi'],
      abi['compilerOutput']['evm']['bytecode'],
      wallet,
    )

    // Deploy contract
    let contract: ethers.Contract
    try {
      contract = await factory.deploy(...parsedInputs, overrides)
      cli.action.start(
        `Deploying ${versionedContractName} to ${contract.address} `,
      )
      // TODO: add numConfirmations to .beltrc
      const receipt = await contract.deployTransaction.wait(1) // wait for 1 confirmation
      cli.action.stop(`Deployed in tx ${receipt.transactionHash}`)
      return contract.address
    } catch (e) {
      this.error(chalk.red(e))
    }
    return
  }
github lucasconstantino / harvest-cli / src / lib / harvest / command.js View on Github external
])

    try {
      this.newLine()
      cli.action.start('Authenticating at Harvest')

      // check if we have authorization using the provided credentials.
      const user = await getClient(access).users.me()

      cli.action.stop('ok!')

      this.log(chalk.bold(`Hello, ${user.first_name}! You are connected ;)`))

      saveConfig({ access, user })
    } catch (err) /* istanbul ignore next */ {
      cli.action.stop('outch!')

      if (err.statusCode !== 401 || !err.error) {
        this.error(err.message)
        this.exit(1)
      }

      this.warn(
        chalk.bold(JSON.parse(err.error).error_description),
        'Please, try again:'
      )

      // try again.
      return this.configure()
    }

    return getConfig()
github heroku / cli / packages / autocomplete / src / hooks / recache.ts View on Github external
const cachePath = path.join(completionsDir, cacheKey)
    const options = await completion.options({config: this.config})
    await updateCache(cachePath, options)
  }

  // if user is not logged in, exit
  try {
    const heroku = new APIClient(this.config)
    if (!heroku.auth) return
    await heroku.get('/account', {retryAuth: false})
  } catch (err) {
    this.debug(err.message)
    return
  }

  cli.action.start('Updating completions')
  await rm()
  await acCreate.run([], this.config)

  try {
    await update(AppCompletion, 'app')
    await update(PipelineCompletion, 'pipeline')
    await update(SpaceCompletion, 'space')
    await update(TeamCompletion, 'team')
  } catch (err) {
    this.debug(err.message)
  }
  cli.action.stop()
}
github stackpath / serverless-scripting-cli / src / api / services / deploy.ts View on Github external
await this.handleScriptUpload(script, i);
        } catch (e) {
          // Check if user wants to try to update subsequent scripts after an error
          await continueOnErrorPrompt(e);
        }
      }

      Log.logVerbose(
        `Saving new configuration file to ${STACKPATH_CONFIGFILE_PATH}`
      );
      fs.writeFileSync(
        configFile,
        JSON.stringify(this.configuration, undefined, 4)
      );

      cliUx.action.stop("Deployment completed.");
    } catch (e) {
      cliUx.action.stop(`An error has occurred. ${e}`);
    }
  }
github SakkuCloud / sakku-cli / src / commands / app / rm.ts View on Github external
async run() {
    const {flags} = this.parse(RM);
    let appId = await cli.prompt('Enter your app id', {required: true});
    if (flags.force) {
      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 {
      let confimation = await cli.confirm('are you really sure to remove? (y/n)');
      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!');
      }
    }
  }
}
github Bearer / bearer-js / packages / cli / src / utils / devPortal.ts View on Github external
export async function withFreshToken(command: BaseCommand) {
  const { expires_at, refresh_token } = (await command.bearerConfig.getToken()) || {
    expires_at: null,
    refresh_token: null
  }

  if (expires_at && refresh_token) {
    try {
      if (expires_at < Date.now()) {
        cliUx.action.start('Refreshing token')
        await refreshMyToken(command, refresh_token)
        cliUx.action.stop()
      }
    } catch (error) {
      cliUx.action.stop(`Failed`)
      command.error(error.message)
    }
  } else {
    await promptToLogin(command)
  }
}
github taneliheikkinen / heroku-wp-environment-sync / src / commands / sync / dbsync.ts View on Github external
const replace_to_text = to_env.replacer(replacement_from.prefix, replacement_from.host, (to_env.app.url) ? to_env.app.url : '', url)
    
                    if(!replace_to_text || !replace_to_text.length) {
                        continue
                    }
                    
                    const from = ((replacement_from.prefix) ? replacement_from.prefix + "://" : '') + replacement_from.host

                    ux.action.status = `Replacing ${Colors.replace(from)} to ${Colors.replace(replace_to_text)}`

                    let amount_of_replaces = parseInt(await WP.runReplaceCommand(from, replace_to_text) as string)

                    amount += amount_of_replaces
                }

                ux.action.stop(`${((amount) ? Colors.success(`${amount} replacements executed!`) : Colors.fail(`Didn't execute any replacements.`))}`)
            }
        }
    }
github taneliheikkinen / heroku-wp-environment-sync / src / lib / CacheHandler.ts View on Github external
static async removeUnfinishedCache () {
        if(!Object.keys(CacheHandler.status).length) {
            return
        }

        ux.action.start(`Removing unfinished caches`)

        for(let cache in CacheHandler.status) {
            if(!CacheHandler.status[cache]) {
                fs.unlinkSync(cache)
                ux.action.status = `Removing ${cache}`
            }
        }

        ux.action.stop()
    }