How to use the cli-ux.warn 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 / run / src / lib / dyno.ts View on Github external
if (this._notified) return
      this._notified = true
      if (!this.opts.notify) return
      // only show notifications if dyno took longer than 20 seconds to start
      if (Date.now() - this._startedAt < 1000 * 20) return

      let notification: Notification & { subtitle?: string } = {
        title: this.opts.app,
        subtitle: `heroku run ${this.opts.command}`,
        message: 'dyno is up'
        // sound: true
      }

      notify(notification)
    } catch (err) {
      cli.warn(err)
    }
  }
}
github cleanunicorn / mythos / src / commands / analyze.ts View on Github external
} 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}`)
    let issues
    const scanner = new Scanner(mythxAddress, mythxPassword)
    try {
      issues = await scanner.run({compiled, contractFile, importedFiles, contractName, timeout, analysisMode})
      cli.action.stop('done')
    } catch (error) {
      cli.error(error, {exit: false})
      cli.action.stop('failed')
      return
github taneliheikkinen / heroku-wp-environment-sync / src / lib / CacheHandler.ts View on Github external
async cacheFolderInit () {
        if(!fs.existsSync(await this.getCacheFolder())) {
            ux.warn(`Sync cache folder doesn't exist.`)

            const create_folder = await ux.confirm(`Wan't to create it?`)
        
            if(create_folder) {
                ux.action.start(`Creating folder to ${await this.getCacheFolder()}`)

                fs.mkdirSync(await this.getCacheFolder(), {
                    recursive : true
                })

                ux.action.stop()
                ux.log()
            }
        }
    }
}
github taneliheikkinen / heroku-wp-environment-sync / src / lib / Apps / RemoteApp.ts View on Github external
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
    }
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 heroku / cli / packages / run / src / lib / colorize.ts View on Github external
other(tokens[4]),
        status(tokens[5]),
        other(tokens[6]),
      ].join('')
    }
    const route = body.match(/^(.* ")(\w+)(.+)(HTTP\/\d+\.\d+" .*)$/)
    if (route) {
      return [
        route[1],
        method(route[2]),
        path(route[3]),
        route[4],
      ].join('')
    }
  } catch (error) {
    ux.warn(error)
  }
  return body
}
github heroku / cli / packages / run / src / lib / colorize.ts View on Github external
return [
        stateChange[1],
        state(stateChange[2]),
        stateChange[3] || '',
        state(stateChange[4] || ''),
      ].join('')
    }
    const exited = body.match(/^(Process exited with status )(\d+)$/)
    if (exited) {
      return [
        exited[1],
        exited[2] === '0' ? c.greenBright(exited[2]) : c.red(exited[2]),
      ].join('')
    }
  } catch (error) {
    ux.warn(error)
  }
  return body
}
github heroku / cli / packages / pipelines / src / commands / pipelines / transfer.ts View on Github external
async run() {
    const {args, flags} = this.parse(PipelinesTransfer)
    const pipeline = await disambiguate(this.heroku, flags.pipeline)
    const newOwner = await getOwner(this.heroku, args.owner)
    const apps = await listPipelineApps(this.heroku, pipeline.id!)
    const displayType = newOwner.type === 'user' ? 'account' : newOwner.type
    let confirmName = flags.confirm

    if (!confirmName) {
      await renderPipeline(this.heroku, pipeline, apps)
      cli.log('')
      cli.warn(`This will transfer ${color.pipeline(pipeline.name!)} and all of the listed apps to the ${args.owner} ${displayType}`)
      cli.warn(`to proceed, type ${color.red(pipeline.name!)} or re-run this command with ${color.red('--confirm')} ${pipeline.name}`)
      confirmName = await cli.prompt('', {})
    }

    if (confirmName !== pipeline.name) {
      cli.warn(`Confirmation did not match ${color.red(pipeline.name!)}. Aborted.`)
      return
    }

    cli.action.start(`Transferring ${color.pipeline(pipeline.name!)} pipeline to the ${args.owner} ${displayType}`)
    await createPipelineTransfer(this.heroku, {pipeline: {id: pipeline.id}, new_owner: newOwner})
    cli.action.stop()
  }
}
github heroku / cli / packages / run / src / lib / colorize.ts View on Github external
}

      if (parts.length === 2) {
        return encodeColor(parts as [string, string])
      }
      return encodeColor([parts[0], parts.splice(1).join('=')])
    })

    return tokens.map(([k, v]) => {
      if (v === undefined) {
        return other(k)
      }
      return other(k + '=') + v
    }).join(' ')
  } catch (error) {
    ux.warn(error)
    return body
  }
}