How to use the cli-ux.cli.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 / buildpacks / src / commands / buildpacks / remove.ts View on Github external
async run() {
    const {args, flags} = this.parse(Remove)
    const buildpackCommand = new BuildpackCommand(this.heroku)

    if (flags.index && args.buildpack) {
      cli.error('Please choose either index or Buildpack, but not both.', {exit: 1})
    }
    if (!flags.index && !args.buildpack) {
      cli.error('Usage: heroku buildpacks:remove [BUILDPACK_URL]. Must specify a buildpack to remove, either by index or URL.')
    }

    const buildpacks = await buildpackCommand.fetch(flags.app)
    if (buildpacks.length === 0) {
      cli.error(`No buildpacks were found. Next release on ${flags.app} will detect buildpack normally.`, {exit: 1})
    }

    let spliceIndex: number
    if (flags.index) {
      buildpackCommand.validateIndexInRange(buildpacks, flags.index)
      spliceIndex = await buildpackCommand.findIndex(buildpacks, flags.index)
    } else {
      spliceIndex = await buildpackCommand.findUrl(buildpacks, args.buildpack)
github heroku / cli / packages / buildpacks / src / commands / buildpacks / remove.ts View on Github external
async run() {
    const {args, flags} = this.parse(Remove)
    const buildpackCommand = new BuildpackCommand(this.heroku)

    if (flags.index && args.buildpack) {
      cli.error('Please choose either index or Buildpack, but not both.', {exit: 1})
    }
    if (!flags.index && !args.buildpack) {
      cli.error('Usage: heroku buildpacks:remove [BUILDPACK_URL]. Must specify a buildpack to remove, either by index or URL.')
    }

    const buildpacks = await buildpackCommand.fetch(flags.app)
    if (buildpacks.length === 0) {
      cli.error(`No buildpacks were found. Next release on ${flags.app} will detect buildpack normally.`, {exit: 1})
    }

    let spliceIndex: number
    if (flags.index) {
      buildpackCommand.validateIndexInRange(buildpacks, flags.index)
      spliceIndex = await buildpackCommand.findIndex(buildpacks, flags.index)
    } else {
      spliceIndex = await buildpackCommand.findUrl(buildpacks, args.buildpack)
    }

    if (spliceIndex === -1) {
github heroku / cli / packages / buildpacks / src / commands / buildpacks / remove.ts View on Github external
async run() {
    const {args, flags} = this.parse(Remove)
    const buildpackCommand = new BuildpackCommand(this.heroku)

    if (flags.index && args.buildpack) {
      cli.error('Please choose either index or Buildpack, but not both.', {exit: 1})
    }
    if (!flags.index && !args.buildpack) {
      cli.error('Usage: heroku buildpacks:remove [BUILDPACK_URL]. Must specify a buildpack to remove, either by index or URL.')
    }

    const buildpacks = await buildpackCommand.fetch(flags.app)
    if (buildpacks.length === 0) {
      cli.error(`No buildpacks were found. Next release on ${flags.app} will detect buildpack normally.`, {exit: 1})
    }

    let spliceIndex: number
    if (flags.index) {
      buildpackCommand.validateIndexInRange(buildpacks, flags.index)
      spliceIndex = await buildpackCommand.findIndex(buildpacks, flags.index)
    } else {
      spliceIndex = await buildpackCommand.findUrl(buildpacks, args.buildpack)
    }

    if (spliceIndex === -1) {
      cli.error('Buildpack not found. Nothing was removed.', {exit: 1})
    }

    if (buildpacks.length === 1) {
      await buildpackCommand.clear(flags.app, 'remove', 'removed')
github heroku / heroku-apps / src / commands / auth / whoami.js View on Github external
notloggedin () {
    cli.error('not logged in', {exitCode: 100})
  }
}
github heroku / cli / packages / buildpacks / src / buildpacks.ts View on Github external
Err: err => {
        cli.error(`Could not find the buildpack: ${buildpack}. ${err}`, {exit: 1})
      },
    }, BuildpackRegistry.isValidBuildpackSlug(buildpack))

    try {
      let response = await this.registry.buildpackExists(buildpack)
      let body = await response.json()
      return body.blob_url
    } catch (err) {
      if (err.statusCode === 404) {
        cli.error(`${buildpack} is not in the buildpack registry.`, {exit: 1})
      } else if (err.statusCode) {
        cli.error(`${err.statusCode}: ${err.message}`, {exit: 1})
      } else {
        cli.error(err.message, {exit: 1})
      }
    }

    return ''
  }
github heroku / cli / packages / buildpacks / src / commands / buildpacks / info.ts View on Github external
Err: err => {
        if (err.status === 404) {
          cli.error(`Could not find the buildpack '${args.buildpack}'`)
        } else {
          cli.error(`Problems finding buildpack info: ${err.description}`)
        }
      }
    }, result)
github heroku / cli / packages / buildpacks / src / commands / buildpacks / remove.ts View on Github external
const buildpacks = await buildpackCommand.fetch(flags.app)
    if (buildpacks.length === 0) {
      cli.error(`No buildpacks were found. Next release on ${flags.app} will detect buildpack normally.`, {exit: 1})
    }

    let spliceIndex: number
    if (flags.index) {
      buildpackCommand.validateIndexInRange(buildpacks, flags.index)
      spliceIndex = await buildpackCommand.findIndex(buildpacks, flags.index)
    } else {
      spliceIndex = await buildpackCommand.findUrl(buildpacks, args.buildpack)
    }

    if (spliceIndex === -1) {
      cli.error('Buildpack not found. Nothing was removed.', {exit: 1})
    }

    if (buildpacks.length === 1) {
      await buildpackCommand.clear(flags.app, 'remove', 'removed')
    } else {
      const buildpackUpdates = await buildpackCommand.mutate(flags.app, buildpacks, spliceIndex, args.buildpack, 'remove')
      buildpackCommand.displayUpdate(flags.app, flags.remote || '', buildpackUpdates, 'removed')
    }
  }
}
github heroku / cli / packages / ps / src / commands / ps / wait.ts View on Github external
parse: input => {
        const w = parseInt(input, 10)
        if (w < 10) {
          cli.error('wait-interval must be at least 10', {exit: 1})
        }
        return w
      },
      default: 10,
github heroku / cli / packages / buildpacks / src / buildpacks.ts View on Github external
validateIndexInRange(buildpacks: BuildpackResponse[], index: number) {
    if (index < 0 || index > buildpacks.length) {
      if (buildpacks.length === 1) {
        cli.error('Invalid index. Only valid value is 1.', {exit: 1})
      } else {
        cli.error(`Invalid index. Please choose a value between 1 and ${buildpacks.length}`, {exit: 1})
      }
    }
  }