Skip to content

Commit

Permalink
feat(cli): add config command (#3817)
Browse files Browse the repository at this point in the history
  • Loading branch information
imhoffd authored Nov 19, 2020
1 parent b1c2718 commit d3d7f89
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ export async function run(): Promise<void> {

program.version(config.cli.package.version);

program
.command('config', { hidden: true })
.description(`print evaluated Capacitor config`)
.option('--json', 'Print in JSON format')
.action(async ({ json }) => {
const { configCommand } = await import('./tasks/config');
await configCommand(config, json);
});

program
.command('create [directory] [name] [id]', { hidden: true })
.description('Creates a new Capacitor project')
Expand Down
17 changes: 17 additions & 0 deletions cli/src/tasks/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import util from 'util';

import type { Config } from '../definitions';
import { output } from '../log';

export async function configCommand(
config: Config,
json: boolean,
): Promise<void> {
if (json) {
output.write(JSON.stringify(config));
} else {
output.write(
`${util.inspect(config, { depth: Infinity, colors: true })}\n`,
);
}
}

0 comments on commit d3d7f89

Please sign in to comment.