How to use the @heroku-cli/command.flags.integer function in @heroku-cli/command

To help you get started, we’ve selected a few @heroku-cli/command 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
import {Command, flags as Flags} from '@heroku-cli/command'
import {cli} from 'cli-ux'

import {BuildpackCommand} from '../../buildpacks'

export default class Remove extends Command {
  static description = 'remove a buildpack set on the app'

  static flags = {
    app: Flags.app({required: true}),
    remote: Flags.remote(),
    index: Flags.integer({
      description: 'the 1-based index of the URL to remove from the list of URLs',
      char: 'i',
    }),
  }

  static args = [
    {
      name: 'buildpack',
      description: 'namespace/name of the buildpack',
    },
  ]

  async run() {
    const {args, flags} = this.parse(Remove)
    const buildpackCommand = new BuildpackCommand(this.heroku)
github heroku / cli / packages / ps / src / commands / ps / wait.ts View on Github external
import {Command, flags} from '@heroku-cli/command'
import {cli} from 'cli-ux'

import {Dyno, Release} from '@heroku-cli/schema'

export default class Wait extends Command {
  static description = 'wait for all dynos to be running latest version after a release'

  static flags = {
    app: flags.app({required: true}),
    remote: flags.remote(),
    type: flags.string({
      char: 't',
      description: 'wait for one specific dyno type',
    }),
    'wait-interval': flags.integer({
      char: 'w',
      description: 'how frequently to poll in seconds (to avoid hitting Heroku API rate limits)',
      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,
    }),
    'with-run': flags.boolean({
      char: 'R',
      description: 'whether to wait for one-off run dynos',
      exclusive: ['type'],
    }),
github heroku / cli / packages / buildpacks / src / commands / buildpacks / set.ts View on Github external
import {Command, flags as Flags} from '@heroku-cli/command'

import {BuildpackCommand} from '../../buildpacks'

export default class Set extends Command {
  static description: 'set new app buildpack, overwriting into list of buildpacks if necessary'
  static flags = {
    app: Flags.app({required: true}),
    remote: Flags.remote(),
    index: Flags.integer({
      description: 'the 1-based index of the URL in the list of URLs',
      char: 'i'
    })
  }
  static args = [
    {
      name: 'buildpack',
      required: true,
      description: 'namespace/name of the buildpack'
    }
  ]

  async run() {
    let {args, flags} = this.parse(Set)

    if (flags.index && flags.index < 0) {
github heroku / cli / packages / run / src / commands / logs.ts View on Github external
export default class Logs extends Command {
  static description = `display recent log output
disable colors with --no-color, HEROKU_LOGS_COLOR=0, or HEROKU_COLOR=0`

  static examples = [
    '$ heroku logs --app=my-app',
    '$ heroku logs --num=50',
    '$ heroku logs --dyno=web --app=my-app',
    '$ heroku logs --app=my-app --tail'
  ]

  static flags = {
    app: flags.app({required: true}),
    remote: flags.remote(),
    num: flags.integer({char: 'n', description: 'number of lines to display'}),
    ps: flags.string({char: 'p', description: 'hidden alias for dyno', hidden: true}),
    dyno: flags.string({
      char: 'd',
      description: 'only show output from this dyno type (such as "web" or "worker")',
      completion: ProcessTypeCompletion
    }),
    source: flags.string({char: 's', description: 'only show output from this source (such as "app" or "heroku")'}),
    tail: flags.boolean({char: 't', description: 'continually stream logs'}),
    'force-colors': flags.boolean({description: 'force use of colors (even on non-tty output)'})
  }

  async run() {
    let {flags} = this.parse(Logs)

    color.enabled = flags['force-colors'] || color.enabled
github heroku / cli / packages / ps / src / commands / ps / autoscale / enable.ts View on Github external
import * as Heroku from '@heroku-cli/schema'
import {cli} from 'cli-ux'

const METRICS_HOST = 'api.metrics.heroku.com'

const isPerfOrPrivateTier = (size: string) => {
  const applicableTiers = ['performance', 'private', 'shield']
  return applicableTiers.some(tier => size.toLowerCase().includes(tier))
}

export default class Enable extends Command {
  static description = 'enable web dyno autoscaling'
  static flags = {
    app: flags.app({required: true}),
    remote: flags.remote(),
    min: flags.integer({required: true, description: 'minimum number of dynos'}),
    max: flags.integer({required: true, description: 'maximum number of dynos'}),
    p95: flags.integer({description: 'desired p95 response time'}),
    notifications: flags.boolean({description: 'receive email notifications when the max dyno limit is reached'})
  }

  async run() {
    const {flags} = this.parse(Enable)
    cli.action.start('Enabling dyno autoscaling')

    const [appResponse, formationResponse] = await Promise.all([
      this.heroku.get(`/apps/${flags.app}`),
      this.heroku.get(`/apps/${flags.app}/formation`)
    ])
    const app = appResponse.body
    const formations = formationResponse.body
    const webFormation = formations.find((f: any) => f.type === 'web')
github heroku / cli / packages / ps / src / commands / ps / autoscale / enable.ts View on Github external
const METRICS_HOST = 'api.metrics.heroku.com'

const isPerfOrPrivateTier = (size: string) => {
  const applicableTiers = ['performance', 'private', 'shield']
  return applicableTiers.some(tier => size.toLowerCase().includes(tier))
}

export default class Enable extends Command {
  static description = 'enable web dyno autoscaling'
  static flags = {
    app: flags.app({required: true}),
    remote: flags.remote(),
    min: flags.integer({required: true, description: 'minimum number of dynos'}),
    max: flags.integer({required: true, description: 'maximum number of dynos'}),
    p95: flags.integer({description: 'desired p95 response time'}),
    notifications: flags.boolean({description: 'receive email notifications when the max dyno limit is reached'})
  }

  async run() {
    const {flags} = this.parse(Enable)
    cli.action.start('Enabling dyno autoscaling')

    const [appResponse, formationResponse] = await Promise.all([
      this.heroku.get(`/apps/${flags.app}`),
      this.heroku.get(`/apps/${flags.app}/formation`)
    ])
    const app = appResponse.body
    const formations = formationResponse.body
    const webFormation = formations.find((f: any) => f.type === 'web')
    if (!webFormation) throw new Error(`${flags.app} does not have any web dynos to scale`)
github heroku / cli / packages / auth / src / commands / auth / login.ts View on Github external
import color from '@heroku-cli/color'
import {Command, flags} from '@heroku-cli/command'
import * as Heroku from '@heroku-cli/schema'

export default class Login extends Command {
  static description = 'login with your Heroku credentials'
  static aliases = ['login']
  static flags = {
    browser: flags.string({description: 'browser to open SSO with (example: "firefox", "safari")'}),
    sso: flags.boolean({hidden: true, char: 's', description: 'login for enterprise users under SSO'}),
    interactive: flags.boolean({char: 'i', description: 'login with username/password'}),
    'expires-in': flags.integer({char: 'e', description: 'duration of token in seconds (default 1 year)'}),
  }

  async run() {
    const {flags} = await this.parse(Login)
    let method: 'interactive' | undefined
    if (flags.interactive) method = 'interactive'
    await this.heroku.login({method, expiresIn: flags['expires-in'], browser: flags.browser})
    const {body: account} = await this.heroku.get('/account', {retryAuth: false})
    this.log(`Logged in as ${color.green(account.email!)}`)
    await this.config.runHook('recache', {type: 'login'})
  }
}
github heroku / cli / packages / ps / src / commands / ps / autoscale / enable.ts View on Github external
import {cli} from 'cli-ux'

const METRICS_HOST = 'api.metrics.heroku.com'

const isPerfOrPrivateTier = (size: string) => {
  const applicableTiers = ['performance', 'private', 'shield']
  return applicableTiers.some(tier => size.toLowerCase().includes(tier))
}

export default class Enable extends Command {
  static description = 'enable web dyno autoscaling'
  static flags = {
    app: flags.app({required: true}),
    remote: flags.remote(),
    min: flags.integer({required: true, description: 'minimum number of dynos'}),
    max: flags.integer({required: true, description: 'maximum number of dynos'}),
    p95: flags.integer({description: 'desired p95 response time'}),
    notifications: flags.boolean({description: 'receive email notifications when the max dyno limit is reached'})
  }

  async run() {
    const {flags} = this.parse(Enable)
    cli.action.start('Enabling dyno autoscaling')

    const [appResponse, formationResponse] = await Promise.all([
      this.heroku.get(`/apps/${flags.app}`),
      this.heroku.get(`/apps/${flags.app}/formation`)
    ])
    const app = appResponse.body
    const formations = formationResponse.body
    const webFormation = formations.find((f: any) => f.type === 'web')
    if (!webFormation) throw new Error(`${flags.app} does not have any web dynos to scale`)
github heroku / cli / packages / buildpacks / src / commands / buildpacks / add.ts View on Github external
import {Command, flags as Flags} from '@heroku-cli/command'

import {BuildpackCommand} from '../../buildpacks'

export default class Add extends Command {
  static description = 'add new app buildpack, inserting into list of buildpacks if necessary'

  static flags = {
    app: Flags.app({required: true}),
    remote: Flags.remote(),
    index: Flags.integer({
      description: 'the 1-based index of the URL in the list of URLs',
      char: 'i',
    }),
  }

  static args = [
    {
      name: 'buildpack',
      required: true,
      description: 'namespace/name of the buildpack',
    },
  ]

  async run() {
    const {args, flags} = this.parse(Add)
    const buildpackCommand = new BuildpackCommand(this.heroku)