How to use the cli-ux.cli.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 adobe / aio-cli-plugin-runtime / src / commands / runtime / property / get.js View on Github external
result = await response.json()
        debug(JSON.stringify(result, null, 2))
      } catch (err) {
        debug(err)
      }

      if (flags.all || flags.apibuild) {
        data.push({ Property: PropertyGet.flags.apibuild.description, Value: result.build })
      }

      if (flags.all || flags.apibuildno) {
        data.push({ Property: PropertyGet.flags.apibuildno.description, Value: result.buildno })
      }
    }

    cli.table(data,
      {
        Property: { minWidth: 10 },
        Value: { minWidth: 20 }
      },
      {
        printLine: this.log,
        'no-truncate': true,
        ...flags // parsed flags
      })
  }
}
github satyarohith / shark / src / commands / domains / list.js View on Github external
const {cli} = require('cli-ux');
        const {calculatePages} = require('../../common');

        const data = [];

        body.domains.map(domain =>
          data.push({
            name: domain.name,
            ttl: domain.ttl,
            zone_file: domain.zone_file
          })
        );

        const {currentPage, totalPages} = calculatePages(body.links);

        cli.table(data, columns, options);
        if (totalPages > 1) {
          this.log('Current Page:', currentPage);
          this.log('Total Pages:', totalPages);
        }
      }
    } catch (error) {
      spinner.stop();
      this.error(error.message);
    }
  }
}
github adobe / aio-cli-plugin-runtime / src / commands / runtime / namespace / list.js View on Github external
async run () {
    try {
      const { flags } = this.parse(NamespaceList)
      const ow = await this.wsk()
      const result = await ow.namespaces.list()

      if (flags.json) {
        this.logJSON('', result)
      } else {
        const columns = {
          namespaces: {
            minWidth: 20,
            get: row => row
          }
        }
        cli.table(result, columns)
      }
    } catch (err) {
      this.handleError('failed to list namespaces', err)
    }
  }
}
github satyarohith / shark / src / commands / actions / list.js View on Github external
body.actions.map(action =>
          data.push({
            id: action.id,
            status: action.status,
            resource_type: action.resource_type,
            resource_id: action.resource_id,
            type: action.type,
            started_at: new Date(action.started_at).toUTCString(),
            completed_at: new Date(action.completed_at).toUTCString(),
            region: action.region_slug
          })
        );

        const {currentPage, totalPages} = calculatePages(body.links);

        cli.table(data, columns, options);
        if (totalPages > 1) {
          this.log('Current Page:', currentPage);
          this.log('Total Pages:', totalPages);
        }
      }
    } catch (error) {
      spinner.stop();
      this.error(error.message);
    }
  }
}
github celo-org / celo-monorepo / packages / cli / src / commands / election / current.ts View on Github external
async run() {
    const res = this.parse(ElectionCurrent)
    cli.action.start('Fetching currently elected Validators')
    const election = await this.kit.contracts.getElection()
    const validators = await this.kit.contracts.getValidators()
    const signers = await election.getCurrentValidatorSigners()
    const validatorList = await Promise.all(
      signers.map((addr) => validators.getValidatorFromSigner(addr))
    )
    cli.action.stop()
    cli.table(validatorList, validatorTable, { 'no-truncate': !res.flags.truncate })
  }
}
github informalsystems / themis-contract / src / commands / list-identities.ts View on Github external
await cliWrap(this, flags.verbose, async () => {
      const db = await IdentityDB.load(identityDBPath(flags.profile))
      const sorted = db.list()
      if (sorted.length === 0) {
        logger.info('No saved identities yet. Try adding one with the "save-identity" command.')
        return
      }
      const longestID = longestFieldLength(sorted, 'id')
      const longestKeybaseID = longestFieldLength(sorted, 'keybaseID')
      cli.table(sorted, {
        id: {
          header: 'id',
          minWidth: longestID + 5,
        },
        canSignWithKeybase: {
          header: 'can_sign_with_keybase',
          minWidth: 'can_sign_with_keybase'.length + 5,
          get: row => row.canSignWithKeybase() ? 'yes' : '',
        },
        canSignWithImages: {
          header: 'can_sign_with_images',
          minWidth: 'can_sign_with_images'.length + 5,
          get: row => row.canSignWithImages() ? 'yes' : '',
        },
        keybaseID: {
          header: 'keybase_id',
github satyarohith / shark / src / commands / volumes / list.js View on Github external
body.volumes.map(volume => {
          const regionName = volume.region.name;
          const createdAt = volume.created_at;
          delete volume.region;
          delete volume.created_at;

          return data.push({
            region: regionName,
            created_at: new Date(createdAt).toUTCString(),
            ...volume
          });
        });

        const {currentPage, totalPages} = calculatePages(body.links);

        cli.table(data, columns, options);
        if (totalPages > 1) {
          this.log('Current Page:', currentPage);
          this.log('Total Pages:', totalPages);
        }
      }
    } catch (error) {
      spinner.stop();
      this.error(error);
    }
  }
}
github celo-org / celo-monorepo / packages / cli / src / commands / lockedgold / list.ts View on Github external
async run() {
    const { args } = this.parse(List)
    cli.action.start('Fetching commitments...')
    const commitments = await new LockedGoldAdapter(this.web3).getCommitments(args.account)
    cli.action.stop()

    cli.log(chalk.bold.yellow('Total Gold Locked \t') + commitments.total.gold)
    cli.log(chalk.bold.red('Total Account Weight \t') + commitments.total.weight)
    if (commitments.locked.length > 0) {
      cli.table(commitments.locked, {
        noticePeriod: { header: 'NoticePeriod', get: (a) => a.time.toString() },
        value: { get: (a) => a.value.toString() },
      })
    }
    if (commitments.notified.length > 0) {
      cli.table(commitments.notified, {
        availabilityTime: { header: 'AvailabilityTime', get: (a) => a.time.toString() },
        value: { get: (a) => a.value.toString() },
      })
    }
  }
}
github superfly / fly / packages / cli / src / commands / apps / index.ts View on Github external
processResponse(this, res, () => {
      const apps = res.data.data.filter((app: any) => app.type === "nodeproxy_apps")
      cli.table(apps, {
        org: {
          header: "Organization",
          get: (row: any) => row.attributes.org
        },
        name: {
          header: "Name",
          get: (row: any) => row.attributes.name
        },
        version: {
          header: "Version",
          get: (row: any) => row.attributes.version
        }
      })
    })
  }
github superfly / fly / packages / cli / src / commands / releases.ts View on Github external
public async run() {
    const { flags } = this.parse(Releases)

    const client = this.gqlClient(flags)
    const appName = this.getAppName(flags)

    const resp = await client.query({
      query: RELEASES,
      variables: {
        appId: appName
      }
    })

    const { app } = resp.data

    cli.table(app.releases.nodes, {
      version: {
        get: (row: any) => `v${row.version}`
      },
      description: {
        get: (row: any) => row.description
      },
      user: {
        get: (row: any) => row.user.email
      },
      date: {
        get: (row: any) => row.createdAt
      }
    })
  }
}