How to use the cli-ux.error 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 heroku / cli / packages / pipelines / src / commands / pipelines / diff.ts View on Github external
if (!coupling) {
      cli.error(`This app (${targetAppName}) does not seem to be a part of any pipeline`)
      return
    }

    const targetAppId = coupling.app!.id!

    cli.action.start('Fetching apps from pipeline')
    const allApps = await listPipelineApps(this.heroku, coupling.pipeline!.id!)
    cli.action.stop()

    const sourceStage = coupling.stage

    if (!sourceStage) {
      return cli.error(`Unable to diff ${targetAppName}`)
    }

    const downstreamStage = PROMOTION_ORDER[PROMOTION_ORDER.indexOf(sourceStage) + 1]
    if (!downstreamStage || PROMOTION_ORDER.indexOf(sourceStage) < 0) {
      return cli.error(`Unable to diff ${targetAppName}`)
    }

    const downstreamApps = allApps.filter(function (app) {
      return app.coupling.stage === downstreamStage
    })

    if (downstreamApps.length === 0) {
      return cli.error(`Cannot diff ${targetAppName} as there are no downstream apps configured`)
    }

    // Fetch GitHub repo/latest release hash for [target, downstream[0], .., downstream[n]] apps
github cleanunicorn / mythos / src / commands / analyze.ts View on Github external
try {
      ({compiled, importedFiles} = await c.solidity(contractFile, contractFileContent, solcVersion))

      // Check if the contract exists
      if (!(contractName in compiled.contracts[contractFile])) {
        cli.error(`Contract ${contractName} not found.`)
        cli.action.stop('failed')
        return
      }
    } catch (error) {
      if (error.message !== undefined) {
        cli.error(error.message, {exit: false})
      }
      if (error.errors !== undefined) {
        for (let err of error.errors) {
          cli.error(err.formattedMessage, {exit: false})
        }
      }
      cli.action.stop('failed')
      return
    }

    if (compiled.errors !== undefined) {
      for (let warning of compiled.errors) {
        cli.warn(warning.formattedMessage)
      }
    }

    cli.action.stop('done')

    // Analyze the contract code
    cli.action.start(`Analyzing contract ${contractName}`)
github heroku / cli / packages / run / src / lib / dyno.ts View on Github external
sshProc.on('close', () => {
        // there was a problem connecting with the ssh key
        if (lastErr.length > 0 && lastErr.includes('Permission denied')) {
          cli.error('There was a problem connecting to the dyno.')
          if (process.env.SSH_AUTH_SOCK) {
            cli.error('Confirm that your ssh key is added to your agent by running `ssh-add`.')
          }
          cli.error('Check that your ssh key has been uploaded to heroku with `heroku keys:add`.')
          cli.error(`See ${color.cyan('https://devcenter.heroku.com/articles/one-off-dynos#shield-private-spaces')}`)
        }
        // cleanup local server
        localServer.close()
      })
      this.p
github heroku / cli / packages / run / src / lib / dyno.ts View on Github external
sshProc.on('close', () => {
        // there was a problem connecting with the ssh key
        if (lastErr.length > 0 && lastErr.includes('Permission denied')) {
          cli.error('There was a problem connecting to the dyno.')
          if (process.env.SSH_AUTH_SOCK) {
            cli.error('Confirm that your ssh key is added to your agent by running `ssh-add`.')
          }
          cli.error('Check that your ssh key has been uploaded to heroku with `heroku keys:add`.')
          cli.error(`See ${color.cyan('https://devcenter.heroku.com/articles/one-off-dynos#shield-private-spaces')}`)
        }
        // cleanup local server
        localServer.close()
      })
      this.p
github cleanunicorn / mythos / src / commands / analyze.ts View on Github external
cli.action.start(`Compiling contract ${contractFile}`)
    const c = new Compiler()
    let compiled
    let importedFiles
    try {
      ({compiled, importedFiles} = await c.solidity(contractFile, contractFileContent, solcVersion))

      // Check if the contract exists
      if (!(contractName in compiled.contracts[contractFile])) {
        cli.error(`Contract ${contractName} not found.`)
        cli.action.stop('failed')
        return
      }
    } catch (error) {
      if (error.message !== undefined) {
        cli.error(error.message, {exit: false})
      }
      if (error.errors !== undefined) {
        for (let err of error.errors) {
          cli.error(err.formattedMessage, {exit: false})
        }
      }
      cli.action.stop('failed')
      return
    }

    if (compiled.errors !== undefined) {
      for (let warning of compiled.errors) {
        cli.warn(warning.formattedMessage)
      }
    }
github heroku / cli / packages / git / src / git.ts View on Github external
async exec(args: string[]): Promise {
    debug('exec: git %o', args)
    try {
      const {stdout, stderr} = await execFile('git', args)
      if (stderr) process.stderr.write(stderr)
      return stdout.trim()
    } catch (err) {
      if (err.code === 'ENOENT') {
        ux.error('Git must be installed to use the Heroku CLI.  See instructions here: http://git-scm.com')
      }
      throw err
    }
  }
github taneliheikkinen / heroku-wp-environment-sync / src / lib / Apps / RemoteApp.ts View on Github external
async handleMultipleEnvs () {
        ux.warn(`There is multiple db env variables defined (${this.constructEnvList(this.db_envs)}), which one is it?`)

        while(!this.db_env_name.length) {
            const db_env_name = await ux.prompt(`The db env variable name`) as string

            if(!this.hasAppEnv(db_env_name)) {
                ux.warn(`That env variable name (${Colors.env(db_env_name)}) doesn't exist in app (${Colors.app(this.name)})`);

                if(!(await ux.confirm("Want to to try again?"))) {
                    ux.error(`Ok, cannot resolve the db env variable name, so quitting.`)
                }
            } else {
                this.db_env_name = db_env_name
            }
        }

        return true
    }
github taneliheikkinen / heroku-wp-environment-sync / src / lib / MySQL.ts View on Github external
static async toolExists () {
        if(!commandExists.sync("mysql")) {
            ux.error(`It seems that ${Colors.cmd("mysql")} -command doesn't exist! Have you installed mysql?`)
        }

        if(!commandExists.sync("mysqldump")) {
            ux.error(`It seems that ${Colors.cmd("mysqldump")} -command doesn't exist! Have you installed mysql?`)
        }
    }
github taneliheikkinen / heroku-wp-environment-sync / src / lib / Syncfile.ts View on Github external
async getEnvWithName (name : string) {
        for(let env of this.environments) {
            if(env.name == name) {
                return env
            }
        }

        ux.error(`Could not find environment with the name ${name}.`)
    }
github taneliheikkinen / heroku-wp-environment-sync / src / lib / Apps / RemoteApp.ts View on Github external
async handleEnvNotRecognized () {
        ux.warn(`Could not find any of the recognized db env variable names in the app ${Colors.app(this.name)}.`);

        ux.warn(`These are the searched db env variable names: ${this.constructEnvList(this.db_envs)}`);

        ux.log();
                
        while(!this.db_env_name) {
            const input_variable_name = await ux.confirm("Do you want to input the db environment variable name? ")

            if(!input_variable_name) {
                ux.error(`Ok, cannot resolve the db env variable name, so quitting.`)
                return false
            }

            const new_env = await ux.prompt(`Type in the env variable in the app ${Colors.app(this.name)}`)
            
            const exists = await this.hasAppEnv(new_env);

            if(!exists) {
                ux.warn(`The ${Colors.app(new_env)} -app doesn't have that env variable .`);
                continue
            }

            this.db_env_name = new_env;
        }

        return true