Skip to content

Commit

Permalink
feat(domain-list): Improved the output of the domain list, use a tabl…
Browse files Browse the repository at this point in the history
…e to format it nicely #14

Merge pull request #14 from entrostat/feature/domain-list-table
  • Loading branch information
kerren authored Mar 12, 2022
2 parents a517390 + 0b850e8 commit 62d2db3
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/commands/domain/list.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BaseCommand } from '../../shared/base.command';
import { CliUx } from '@oclif/core';

export default class DomainList extends BaseCommand {
static description = 'Lists the existing domains that have been registered';
Expand All @@ -11,9 +12,31 @@ export default class DomainList extends BaseCommand {

public async run(): Promise<void> {
const config = await this.getConfig();
config.domains.forEach((domain) => {
this.log(`127.0.0.1:${domain.port} ---> https://${domain.domain}`);
});

CliUx.ux.table(
config.domains
.map((d) => ({
domain: `https://${d.domain}`,
port: d.port.toString(),
}))
.sort((a, b) => {
if (a === b) {
return 0;
}
return a < b ? -1 : 1;
}),
{
domain: {
header: 'Domain',
},
port: {
header: 'Port',
},
},
{
printLine: this.log.bind(this),
},
);

if (config.domains.length === 0) {
this.log('No domains registered...');
Expand Down

0 comments on commit 62d2db3

Please sign in to comment.