How to use the cli-ux.cli.styledObject 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 / oauth / src / lib / authorizations.ts View on Github external
obj.Client = auth.client.name
    obj['Redirect URI'] = auth.client.redirect_uri
  }

  if (auth.access_token) {
    obj.Token = auth.access_token.token
    if (auth.updated_at) {
      obj['Updated at'] = `${addSeconds(auth.updated_at, 0)} (${distanceInWordsToNow(auth.updated_at)} ago)`
    }
    if (auth.access_token.expires_in) {
      const date = addSeconds(new Date(), auth.access_token.expires_in)
      obj['Expires at'] = `${date} (in ${distanceInWordsToNow(date)})`
    }
  }

  cli.styledObject(obj, [
    'Client',
    'Redirect URI',
    'ID',
    'Description',
    'Scope',
    'Token',
    'Expires at',
    'Updated at',
  ])
}
github heroku / cli / packages / webhooks / src / commands / webhooks / deliveries / info.ts View on Github external
const obj = {
      Created: delivery.created_at,
      Event: delivery.event.id,
      Webhook: delivery.webhook.id,
      Status: delivery.status,
      Include: delivery.event.include,
      Level: delivery.webhook.level,
      Attempts: delivery.num_attempts,
      Code: delivery.last_attempt && delivery.last_attempt.code,
      Error: delivery.last_attempt && delivery.last_attempt.error_class,
      'Next Attempt': delivery.next_attempt_at
    }

    cli.styledHeader(delivery.id)
    cli.styledObject(obj)

    cli.styledHeader('Event Payload')
    cli.styledJSON(event.payload)
  }
}
github heroku / cli / packages / oauth / src / commands / clients / info.ts View on Github external
async run() {
    const {args, flags} = this.parse(ClientsInfo)

    const {body: client} = await this.heroku.get(`/oauth/clients/${args.id}`)

    if (flags.json) {
      cli.styledJSON(client)
    } else if (flags.shell) {
      cli.log(`HEROKU_OAUTH_ID=${client.id}`)
      cli.log(`HEROKU_OAUTH_SECRET=${client.secret}`)
    } else {
      cli.styledHeader(`${client.name}`)
      cli.styledObject(client)
    }
  }
}
github heroku / cli / packages / webhooks / src / commands / webhooks / events / info.ts View on Github external
async run() {
    const {flags, args} = this.parse(Info)
    const {path} = this.webhookType(flags)

    cli.warn('heroku webhooks:event:info is deprecated, please use heroku webhooks:deliveries:info')

    const {body: webhookEvent} = await this.webhooksClient.get(`${path}/webhook-events/${args.id}`)

    const obj = {
      payload: JSON.stringify(webhookEvent.payload, null, 2),
    }

    cli.styledHeader(webhookEvent.id)
    cli.styledObject(obj)
  }
}
github heroku / cli / packages / buildpacks / src / commands / buildpacks / info.ts View on Github external
Ok: buildpack => {
        cli.styledHeader(args.buildpack)
        cli.styledObject(buildpack, ['description', 'category', 'license', 'support', 'source', 'readme'])
      },
      Err: err => {
github heroku / cli / packages / oauth / src / commands / clients / rotate.ts View on Github external
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()

    if (flags.json) {
      cli.styledJSON(client)
    } else if (flags.shell) {
      cli.log(`HEROKU_OAUTH_ID=${client.id}`)
      cli.log(`HEROKU_OAUTH_SECRET=${client.secret}`)
    } else {
      cli.styledHeader(`${client.name}`)
      cli.styledObject(client)
    }
  }
}
github heroku / cli / packages / webhooks / src / commands / webhooks / info.ts View on Github external
async run() {
    const {flags, args} = this.parse(WebhooksInfo)
    const {path} = this.webhookType(flags)

    const {body: webhook} = await this.webhooksClient.get(`${path}/webhooks/${args.id}`)

    const obj = {
      'Webhook ID': webhook.id,
      URL: webhook.url,
      Include: webhook.include.join(','),
      Level: webhook.level,
    }

    cli.styledHeader(webhook.id)
    cli.styledObject(obj)
  }
}