How to use the cli-ux.table 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 / ci / src / utils / test-run.ts View on Github external
let data: any = []

  latestTestRuns.forEach(testRun => {
    data.push(
      {
        iconStatus: `${statusIcon(testRun)}`,
        number: testRun.number,
        branch: testRun.commit_branch,
        sha: testRun.commit_sha!.slice(0, 7),
        status: testRun.status
      }
    )
  })

  cli.table(data, {
    printHeader: undefined,
    columns: [
      {key: 'iconStatus', width: 1, label: ''}, // label '' is to make sure that widh is 1 character
      {key: 'number', label: ''},
      {key: 'branch'},
      {key: 'sha'},
      {key: 'status'}
    ]
  })

  if (watchOption) {
    process.stdout.write(ansiEscapes.cursorUp(latestTestRuns.length))
  }
}
github lucasconstantino / harvest-cli / src / commands / log / list.js View on Github external
async run () {
    const {
      flags: { 'per-page': per_page, page, ...options }
    } = this.parse(LogListCommand)

    cli.action.start('Loading your time entries')

    const { time_entries } = await this.loadTimeEntries({ per_page, page })

    cli.action.stop('here they are!')

    this.newLine()

    /* istanbul ignore next */
    cli.table(
      time_entries,
      {
        id: {},
        date: { get: ({ created_at }) => created_at },
        client: { get: ({ client: { name } }) => name },
        project: { get: ({ project: { name } }) => name },
        task: { get: ({ task: { name } }) => name },
        hours: {},
        status: {
          get: ({ is_running }) => (is_running ? 'Running' : 'Finished')
        }
      },
      options
    )

    // console.log(JSON.stringify(time_entries, null, 2))
github heroku / cli / packages / pipelines / src / commands / pipelines / diff.ts View on Github external
const githubDiff: any = await HTTP.get(`https://api.github.com/repos/${path}`, {
      headers,
    }).then(res => res.body)

    cli.log('')
    cli.styledHeader(`${color.app(targetApp.name)} is ahead of ${color.app(downstreamApp.name)} by ${githubDiff.ahead_by} commit${githubDiff.ahead_by === 1 ? '' : 's'}`)
    const mapped = githubDiff.commits.map((commit: any) => {
      return {
        sha: commit.sha.substring(0, 7),
        date: commit.commit.author.date,
        author: commit.commit.author.name,
        message: commit.commit.message.split('\n')[0],
      }
    }).reverse()
    cli.table(mapped, {
      sha: {
        header: 'SHA',
      },
      date: {},
      author: {},
      message: {},
    })
    cli.log(`\nhttps://github.com/${path}`)
  // tslint:disable-next-line: no-unused
  } catch (error) {
    cli.log(`\n${color.app(targetApp.name)} was not compared to ${color.app(downstreamApp.name)} because we were unable to perform a diff`)
    cli.log('are you sure you have pushed your latest commits to GitHub?')
  }
}
github heroku / cli / packages / pipelines / src / render-pipeline.ts View on Github external
const email = row.owner && row.owner.email

        if (email) {
          return email.endsWith('@herokumanager.com') ? `${row.split('@')[0]} (team)` : email
        }
      },
    }
  }

  const developmentApps = sortBy(pipelineApps.filter(app => app.coupling.stage === 'development'), ['name'])
  const reviewApps = sortBy(pipelineApps.filter(app => app.coupling.stage === 'review'), ['name'])
  const stagingApps = sortBy(pipelineApps.filter(app => app.coupling.stage === 'staging'), ['name'])
  const productionApps = sortBy(pipelineApps.filter(app => app.coupling.stage === 'production'), ['name'])
  const apps = developmentApps.concat(reviewApps).concat(stagingApps).concat(productionApps)

  cli.table(apps, columns)

  if (showOwnerWarning && pipeline.owner) {
    warnMixedOwnership(pipelineApps, pipeline, owner)
  }
}
github dstack-group / Butterfly / user-manager / buttercli / src / base / base.ts View on Github external
private printTable(result: T[], columns: TableColumns) {
    return cli.table(result, columns, {});
  }
github smartcontractkit / chainlink / belt / src / commands / box.ts View on Github external
private handleList() {
    const versions = getSolidityVersions().map(([alias, full]) => ({
      alias,
      full,
    }))

    this.log(chalk.greenBright('Available Solidity Versions'))
    ux.table(versions, {
      alias: {},
      full: {},
    })
    this.log('')
  }
github heroku / cli / packages / addons / src / commands / _addons / index.ts View on Github external
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) {
              return row.plan.name.replace(/^[^:]+:/, '')
            }
          }
        },
        price: {
          get: row => getPrice(row, flags.app)
        },
        state: {
          get: getAddonState,
          extended: true