How to use the @heroku-cli/command.flags.string 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 / run / src / commands / run / index.ts View on Github external
static examples = [
    '$ heroku run bash',
    '$ 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,
github heroku / cli / packages / run / src / commands / console.ts View on Github external
// tslint:disable:file-name-casing
import {Command, flags} from '@heroku-cli/command'
import {DynoSizeCompletion} from '@heroku-cli/command/lib/completions'

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

export default class RunConsole extends Command {
  static hidden = true

  static flags = {
    app: flags.app({required: true}),
    remote: flags.remote(),
    size: flags.string({char: 's', description: 'dyno size', completion:  DynoSizeCompletion}),
    env: flags.string({char: 'e', description: 'environment variables to set (use \';\' to split multiple vars)'})
  }

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

    let opts = {
      heroku: this.heroku,
      app: flags.app,
      command: buildCommand(['console']),
      size: flags.size,
      env: flags.env,
      attach: true
    }

    let dyno = new Dyno(opts)
github heroku / cli / packages / webhooks-v5 / commands / webhooks / update.js View on Github external
Update.description = 'updates a webhook in an app'

Update.examples = [
  '$ heroku webhooks:update 99999999-9999-9999-9999-999999999999 -i dyno -l notify -s 09928c40bf1b191b645174a19f7053d16a180da37332e719ef0998f4c0a2 -u https://example.com/hooks'
]

Update.flags = {
  app: flags.app(),
  remote: flags.remote(),
  pipeline: flags.string({ char: 'p', description: 'pipeline on which to list', hidden: true }),
  include: flags.string({ char: 'i', description: 'comma delimited event types your server will receive ', required: true }),
  level: flags.string({ char: 'l', description: 'notify does not retry, sync will retry until successful or timeout', required: true }),
  secret: flags.string({ char: 's', description: 'value to sign delivery with in Heroku-Webhook-Hmac-SHA256 header' }),
  authorization: flags.string({ char: 't', description: 'authoriation header to send with webhooks' }),
  url: flags.string({ char: 'u', description: 'URL for receiver', required: true })
}

Update.args = [
  { name: 'id' }
]

module.exports = Update

//
// 'use strict'
//
// let co = require('co')
// let cli = require('heroku-cli-util')
// let webhookType = require('../../lib/webhook-type.js')
//
// function * run(context, heroku) {
github heroku / cli / packages / oauth / src / commands / authorizations / create.ts View on Github external
import {cli} from 'cli-ux'

import {display} from '../../lib/authorizations'

export default class AuthorizationsCreate extends Command {
  static description = 'create a new OAuth authorization'

  static examples = [
    '$ heroku authorizations:create --description "For use with Anvil"',
  ]

  static flags = {
    description: flags.string({char: 'd', description: 'set a custom authorization'}),
    short: flags.boolean({char: 'S', description: 'only output token'}),
    json: flags.boolean({char: 'j', description: 'output in json format'}),
    scope: flags.string({char: 's', description: 'set custom OAuth scopes', completion: ScopeCompletion}),
    'expires-in': flags.string({char: 'e', description: 'set expiration in seconds (default no expiration)'}),
  }

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

    cli.action.start('Creating OAuth Authorization')

    const {body: auth} = await this.heroku.post('/oauth/authorizations', {
      body: {
        description: flags.description,
        scope: flags.scope ? flags.scope.split(',') : undefined,
        expires_in: flags['expires-in'],
      },
    })
github heroku / cli / packages / webhooks / src / commands / webhooks / add.ts View on Github external
import {cli} from 'cli-ux'

import BaseCommand from '../base'

export default class WebhooksAdd extends BaseCommand {
  static description = 'add a webhook to an app'

  static examples = [
    '$ heroku webhooks:add -i api:dyno -l notify -u https://example.com/hooks',
  ]

  static flags = {
    app: flags.app(),
    remote: flags.remote(),
    pipeline: flags.pipeline({char: 'p', description: 'pipeline on which to list', hidden: true}),
    include: flags.string({char: 'i', description: 'comma delimited event types your server will receive ', required: true}),
    level: flags.string({char: 'l', description: 'notify does not retry, sync will retry until successful or timeout', required: true}),
    secret: flags.string({char: 's', description: 'value to sign delivery with in Heroku-Webhook-Hmac-SHA256 header'}),
    authorization: flags.string({char: 't', description: 'authoriation header to send with webhooks'}),
    url: flags.string({char: 'u', description: 'URL for receiver', required: true}),
  }

  async run() {
    const {flags} = this.parse(WebhooksAdd)
    const {path, display} = this.webhookType(flags)

    cli.action.start(`Adding webhook to ${display}`)

    const response = await this.webhooksClient.post(`${path}/webhooks`, {
      body: {
        include: flags.include.split(',').map(s => s.trim()),
        level: flags.level,
github heroku / cli / src / subject_command.ts View on Github external
header: string
  extended: boolean
  minWidth?: number
  width: number
  get(cell: any, row: any): string
}

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
  }
github heroku / cli / packages / webhooks / src / commands / webhooks / add.ts View on Github external
export default class WebhooksAdd extends BaseCommand {
  static description = 'add a webhook to an app'

  static examples = [
    '$ heroku webhooks:add -i api:dyno -l notify -u https://example.com/hooks',
  ]

  static flags = {
    app: flags.app(),
    remote: flags.remote(),
    pipeline: flags.pipeline({char: 'p', description: 'pipeline on which to list', hidden: true}),
    include: flags.string({char: 'i', description: 'comma delimited event types your server will receive ', required: true}),
    level: flags.string({char: 'l', description: 'notify does not retry, sync will retry until successful or timeout', required: true}),
    secret: flags.string({char: 's', description: 'value to sign delivery with in Heroku-Webhook-Hmac-SHA256 header'}),
    authorization: flags.string({char: 't', description: 'authoriation header to send with webhooks'}),
    url: flags.string({char: 'u', description: 'URL for receiver', required: true}),
  }

  async run() {
    const {flags} = this.parse(WebhooksAdd)
    const {path, display} = this.webhookType(flags)

    cli.action.start(`Adding webhook to ${display}`)

    const response = await this.webhooksClient.post(`${path}/webhooks`, {
      body: {
        include: flags.include.split(',').map(s => s.trim()),
        level: flags.level,
        secret: flags.secret,
        url: flags.url,
        authorization: flags.authorization,
github heroku / heroku-api-plugin / src / commands / api.ts View on Github external
FOO: "bar"
  …
}

$ export HEROKU_HEADERS
$ HEROKU_HEADERS='{
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json"
}'
$ printf 'type=web&qty=2' | heroku api POST /apps/myapp/ps/scale
2`]

  static flags = {
    version: flags.string({char: 'v', description: 'version to use (e.g. 2, 3, or 3.variant)'}),
    'accept-inclusion': flags.string({char: 'a', description: 'Accept-Inclusion header to use'}),
    body: flags.string({char: 'b', description: 'JSON input body'})
  }
  static args = [
    {name: 'method', description: 'GET, POST, PUT, PATCH, or DELETE', required: true},
    {name: 'path', description: 'endpoint to call'}
  ]

  async run() {
    const {args, flags} = this.parse(API)
    const getBody = async (): Promise => {
      const getStdin = require('get-stdin')
      const edit = require('edit-string')

      let body = flags.body || await getStdin()
      if (!body) {
        this.warn('no stdin provided')
        return
github heroku / cli / packages / apps / src / commands / domains / add.ts View on Github external
interface DomainCreatePayload {
  hostname: string
  sni_endpoint?: string
}

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) {
github heroku / cli / packages / run / src / commands / logs.ts View on Github external
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

    await logDisplayer(this.heroku, {
      app: flags.app,