How to use the @heroku-cli/command.flags.boolean 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 / apps / src / commands / domains / add.ts View on Github external
}

const MULTIPLE_SNI_ENDPOINT_FLAG = 'allow-multiple-sni-endpoints'

export default class DomainsAdd extends Command {
  static description = 'add a domain to an app'

  static examples = ['heroku domains:add www.example.com']

  static flags = {
    help: flags.help({char: 'h'}),
    app: flags.app({required: true}),
    cert: flags.string({description: 'the name of the SSL cert you want to use for this domain', char: 'c'}),
    json: flags.boolean({description: 'output in json format', char: 'j'}),
    remote: flags.remote(),
    wait: flags.boolean()
  }

  static args = [{name: 'hostname', required: true}]

  createDomain = async (appName: string, payload: DomainCreatePayload): Promise => {
    cli.action.start(`Adding ${color.green(payload.hostname)} to ${color.app(appName)}`)
    try {
      const response = await this.heroku.post(`/apps/${appName}/domains`, {
        headers: {Accept: 'application/vnd.heroku+json; version=3.allow_multiple_sni_endpoints'},
        body: payload
      })
      return response.body
    } catch (err) {
      // If the error indicates that the app has multiple certs needs the user to specify which one
      // to use, we ask them which cert to use, otherwise we rethrow the error and handle it like usual
      if (err.body.id === 'invalid_params' && err.body.message.includes('sni_endpoint')) {
github heroku / cli / packages / heroku-apps / src / commands / regions / index.js View on Github external
// @flow

import {Command, flags} from '@heroku-cli/command'
import {cli} from 'cli-ux'

export default class LabsDisable extends Command {
  static topic = 'regions'
  static description = 'list available regions for deployment'
  static flags = {
    json: flags.boolean({description: 'output in json format'}),
    private: flags.boolean({description: 'show regions for private spaces'}),
    common: flags.boolean({description: 'show regions for common runtime'})
  }

  async run () {
    const sortBy = require('lodash.sortby')

    let {body: regions} = await this.heroku.get('/regions')
    if (this.flags.private) {
      regions = regions.filter(region => region.private_capable)
    } else if (this.flags.common) {
      regions = regions.filter(region => !region.private_capable)
    }
    regions = sortBy(regions, ['private_capable', 'name'])

    if (this.flags.json) {
      cli.styledJSON(regions)
    } else {
github heroku / cli / packages / run / src / commands / run / index.ts View on Github external
'$ heroku run -s hobby -- myscript.sh -a arg1 -s arg2'
  ]

  // This is to allow for variable length arguments
  static strict = false

  static flags = {
    app: flags.app({description: 'parent app used by review apps', required: true}),
    remote: flags.remote(),
    size: flags.string({char: 's', description: 'dyno size', completion: DynoSizeCompletion}),
    type: flags.string({description: 'process type', completion: ProcessTypeCompletion}),
    'exit-code': flags.boolean({char: 'x', description: 'passthrough the exit code of the remote command'}),
    env: flags.string({char: 'e', description: "environment variables to set (use ';' to split multiple vars)"}),
    'no-tty': flags.boolean({description: 'force the command to not run in a tty'}),
    listen: flags.boolean({description: 'listen on a local port', hidden: true}),
    'no-notify': flags.boolean({description: 'disables notification when dyno is up (alternatively use HEROKU_NOTIFICATIONS=0)'})
  }

  async run() {
    const {argv, flags} = this.parse(Run)

    let opts = {
      'exit-code': flags['exit-code'],
      'no-tty': flags['no-tty'],
      app: flags.app,
      attach: true,
      command: buildCommand(argv),
      env: flags.env,
      heroku: this.heroku,
      listen: flags.listen,
      notify: !flags['no-notify'],
      size: flags.size,
github heroku / cli / packages / git / src / commands / git / remote.ts View on Github external
import Git from '../../git'

export class GitRemote extends Command {
  static description = `adds a git remote to an app repo
extra arguments will be passed to git remote add
`
  static example = `# set git remote heroku to https://git.heroku.com/example.git
    $ heroku git:remote -a example

    # set git remote heroku-staging to https://git.heroku.com/example-staging.git
    $ heroku git:remote --remote heroku-staging -a example`
  static flags = {
    app: flags.string({char: 'a', description: 'the Heroku app to use'}),
    remote: flags.string({char: 'r', description: 'the git remote to create'}),
    'ssh-git': flags.boolean({description: 'use SSH git protocol'}),
  }
  static strict = false

  async run() {
    const {argv, flags} = this.parse(GitRemote)
    const git = new Git()
    let appName = flags.app || argv.shift() || process.env.HEROKU_APP
    if (!appName) {
      this.error('Specify an app with --app')
    }
    let {body: app} = await this.heroku.get(`/apps/${appName}`)
    let remote = flags.remote || (await git.remoteFromGitConfig()) || 'heroku'
    let remotes = await git.exec(['remote'])
    let url = git.url(app.name!, flags['ssh-git'])
    if (remotes.split('\n').includes(remote)) {
      await git.exec(['remote', 'set-url', remote, url].concat(argv))
github heroku / cli / src / subject_command.ts View on Github external
export interface OutputOptions {
  extended?: boolean
  full?: boolean
  header?: boolean
}

export default abstract class Subject extends Command {
  static flags = {
    columns: flags.string({char: 'c', exclusive: ['extended']}),
    json: flags.boolean({char: 'j'}),
    sort: flags.string({char: 's', description: 'property to sort by'}),
    csv: flags.boolean({exclusive: ['json']}),
    extended: flags.boolean({char: 'x', description: 'show all properties'}),
    full: flags.boolean({description: 'do not truncate output to fit screen'}),
    'no-header': flags.boolean({exclusive: ['csv', 'json'], description: 'hide header from output'}),
  }

  path!: string[]
  async init(): Promise {
    await super.init()
    let [path, ...argv] = this.argv
    this.path = path.slice(1).split(':')
    this.argv = argv
  }

  output(obj: any, options: {sort?: string, columns: TableColumnOptions[]}) {
    const {flags} = this.parse(Subject)
    const addMissingProps = (row: any) => {
      for (let key of Object.keys(row)) {
        if (options.columns.find(c => c.key === key)) continue
        options.columns.push({
github heroku / cli / packages / run / src / commands / run / inside.ts View on Github external
import Dyno from '../../lib/dyno'
import {buildCommand} from '../../lib/helpers'

const debug = DebugFactory('heroku:run:inside')

export default class RunInside extends Command {
  static description = 'run a one-off process inside an existing heroku dyno'
  static examples = [
    '$ heroku run:inside web.1 bash'
  ]
  static flags = {
    app: flags.app({required: true}),
    remote: flags.remote(),
    'exit-code': flags.boolean({char: 'x', description: 'passthrough the exit code of the remote command'}),
    env: flags.string({char: 'e', description: "environment variables to set (use ';' to split multiple vars)"}),
    listen: flags.boolean({description: 'listen on a local port', hidden: true})
  }
  static strict = false

  async run() {
    let {flags, argv} = this.parse(RunInside)

    if (argv.length < 2) {
      throw new Error('Usage: heroku run:inside DYNO COMMAND\n\nExample: heroku run:inside web.1 bash')
    }

    let opts = {
      'exit-code': flags['exit-code'],
      app: flags.app,
      command: buildCommand(argv.slice(1)),
      dyno: argv[0],
      env: flags.env,
github heroku / cli / packages / ps / src / commands / ps / wait.ts View on Github external
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'],
    }),
  }

  async run() {
    const {flags} = this.parse(Wait)

    const {body: releases} = await this.heroku.request(`/apps/${flags.app}/releases`, {
      partial: true,
      headers: {
        Range: 'version ..; max=1, order=desc',
      },
    })
github heroku / cli / packages / oauth / src / commands / clients / rotate.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'
import {cli} from 'cli-ux'

export default class ClientsRotate extends Command {
  static description = 'rotate OAuth client secret'

  static flags = {
    json: flags.boolean({char: 'j', description: 'output in json format'}),
    shell: flags.boolean({char: 's', description: 'output in shell format'}),
  }

  static args = [{name: 'id', required: true}]

  async run() {
    const {args, flags} = this.parse(ClientsRotate)

    cli.action.start(`Updating ${color.cyan(args.id)}`)

    const {body: client} = await this.heroku.post(
      `/oauth/clients/${encodeURIComponent(args.id)}/actions/rotate-credentials`,
    )

    cli.action.stop()
github heroku / cli / packages / run / src / commands / rake.ts View on Github external
import {DynoSizeCompletion} from '@heroku-cli/command/lib/completions'
import cli from 'cli-ux'

import Dyno from '../lib/dyno'
import {buildCommand} from '../lib/helpers'

export default class RunRake extends Command {
  static hidden = true
  static strict = false
  static flags = {
    app: flags.app({description: 'parent app used by review apps', required: true}),
    remote: flags.remote(),
    size: flags.string({char: 's', description: 'dyno size', completion: DynoSizeCompletion}),
    'exit-code': flags.boolean({char: 'x', description: 'passthrough the exit code of the remote command'}),
    env: flags.string({char: 'e', description: "environment variables to set (use ';' to split multiple vars)"}),
    'no-tty': flags.boolean({description: 'force the command to not run in a tty'}),
  }

  async run() {
    let {flags, argv} = this.parse(RunRake)

    let opts = {
      heroku: this.heroku,
      app: flags.app,
      command: buildCommand(['rake', ...argv]),
      size: flags.size,
      'exit-code': flags['exit-code'],
      env: flags.env,
      'no-tty': flags['no-tty'],
      attach: true
    }
github heroku / cli / packages / run / src / commands / logs.ts View on Github external
'$ 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

    await logDisplayer(this.heroku, {
      app: flags.app,
      dyno: flags.dyno || flags.ps,
      lines: flags.num || 100,
      tail: flags.tail,
      source: flags.source
    })
  }