How to use the cli-ux.cli.log 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 RocketChat / Rocket.Chat.Apps-cli / src / misc / cloudAuth.ts View on Github external
const code = request.query.code;
                            const token = await this.fetchToken(code);

                            resolve(token.access_token);
                            return 'Thank you. You can close this tab.';
                        } catch (err) {
                            reject(err);
                        } finally {
                            this.server.stop();
                        }
                    },
                });

                const codeChallenge = this.base64url(createHash('sha256').update(this.codeVerifier).digest('base64'));
                const authorizeUrl = this.buildAuthorizeUrl(codeChallenge);
                cli.log(chalk.green('*') + ' ' + chalk.white('...if your browser does not open, open this:')
                    + ' ' + chalk.underline(chalk.blue(authorizeUrl)));

                open(authorizeUrl);

                this.server.start();
            } catch (e) {
                // tslint:disable-next-line:no-console
                console.log('Error inside of the execute:', e);
            }
        });
    }
github fauna / fauna-shell / src / commands / cloud-login.js View on Github external
saveEndpointOrError(newEndpoint, alias, secret).then(function (_) {
        const msg = `Endpoint '${alias}' saved.`
        cli.log(msg)
        res.end(msg)
        server.close(err => process.exit())
      })
      .catch(function (err) {
github heroku / cli / packages / buildpacks / src / buildpacks.ts View on Github external
display(buildpacks: BuildpackResponse[], indent: string) {
    if (buildpacks.length === 1) {
      cli.log(this.registryUrlToName(buildpacks[0].buildpack.url, true))
    } else {
      buildpacks.forEach((b, i) => {
        cli.log(`${indent}${i + 1}. ${this.registryUrlToName(b.buildpack.url, true)}`)
      })
    }
  }
github heroku / cli / packages / oauth / src / commands / clients / rotate.ts View on Github external
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()

    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 / config / src / commands / config / edit.ts View on Github external
private async diffPrompt(original: Config, newConfig: Config): Promise {
    if (_.isEqual(original, newConfig)) {
      this.warn('no changes to config')
      return false
    }
    cli.log()
    cli.log('Config Diff:')
    showDiff(original, newConfig)
    cli.log()
    return cli.confirm(`Update config on ${color.app(this.app)} with these values?`)
  }
github heroku / cli / packages / oauth / src / commands / clients / create.ts View on Github external
const {redirect_uri, name} = args
    validateURL(redirect_uri)

    cli.action.start(`Creating ${args.name}`)

    const {body: client} = await this.heroku.post('/oauth/clients', {
      body: {name, redirect_uri},
    })

    cli.action.stop()

    if (flags.json) {
      cli.styledJSON(client)
    } else {
      cli.log(`HEROKU_OAUTH_ID=${client.id}`)
      cli.log(`HEROKU_OAUTH_SECRET=${client.secret}`)
    }
  }
}
github heroku / cli / packages / oauth / src / commands / authorizations / index.ts View on Github external
async run() {
    const {flags} = this.parse(AuthorizationsIndex)

    let {body: authorizations} = await this.heroku.get>('/oauth/authorizations')

    authorizations = sortBy(authorizations, 'description')

    if (flags.json) {
      cli.styledJSON(authorizations)
    } else if (authorizations.length === 0) {
      cli.log('No OAuth authorizations.')
    } else {
      cli.table(authorizations, {
        description: {get: (v: any) => color.green(v.description)},
        id: {},
        scope: {get: (v: any) => v.scope.join(',')},
      }, {'no-header': true, printLine: this.log})
    }
  }
}
github heroku / cli / packages / addons / src / commands / _addons / index.ts View on Github external
if ((!flags.app) && (!flags.all)) {
      cli.error('You need to specify the scope via --app or --all')
    }

    if (flags.app) {
      url = `/apps/${flags.app}/addons`
    } else {
      url = '/addons'
    }

    const headers = {'Accept-Expansion': 'addon_service, plan'}
    const {body: addons} = await this.heroku.get(url, {headers})

    if (addons.length === 0) {
      if (flags.app) {
        cli.log(`No add-ons for app ${flags.app}`)
      } else {
        cli.log('No add-ons on your apps')
      }
      return
    }

    if (flags.json) {
      ux.styledJSON(addons)
    } else {
      ux.table(addons, {
        name: {
          get: getAddonName
        },
        plan: {
          get: row => {
            if (row.plan && row.plan.name) {
github heroku / cli / packages / buildpacks / src / commands / buildpacks / search.ts View on Github external
columns: [
          {key: 'buildpack', label: 'Buildpack'},
          {key: 'category', label: 'Category'},
          {key: 'description', label: 'Description', format: trunc}
        ]
      })
    }

    if (buildpacks.length === 0) {
      cli.log('No buildpacks found')
    } else if (buildpacks.length === 1) {
      displayTable(buildpacks)
      cli.log('\n1 buildpack found')
    } else {
      displayTable(buildpacks)
      cli.log(`\n${buildpacks.length} buildpacks found`)
    }
  }
}
github heroku / cli / packages / buildpacks / src / commands / buildpacks / search.ts View on Github external
description: buildpack.description
      }
    })
    const trunc = (value: string, _: string) => truncate(value, {length: 35, omission: '…'})
    let displayTable = (buildpacks: TableRow[]) => {
      cli.table(buildpacks, {
        columns: [
          {key: 'buildpack', label: 'Buildpack'},
          {key: 'category', label: 'Category'},
          {key: 'description', label: 'Description', format: trunc}
        ]
      })
    }

    if (buildpacks.length === 0) {
      cli.log('No buildpacks found')
    } else if (buildpacks.length === 1) {
      displayTable(buildpacks)
      cli.log('\n1 buildpack found')
    } else {
      displayTable(buildpacks)
      cli.log(`\n${buildpacks.length} buildpacks found`)
    }
  }
}