diff --git a/cli/bifravst.ts b/cli/bifravst.ts index 344b4246..6d5c2d0a 100644 --- a/cli/bifravst.ts +++ b/cli/bifravst.ts @@ -8,6 +8,7 @@ import { cdCommand } from './commands/cd' import { generateCertCommand } from './commands/generate-cert' import { connectCommand } from './commands/connect' import { reactConfigCommand } from './commands/react-config' +import { infoCommand } from './commands/info' import { registerCaCommand } from './commands/register-ca' import { historicalDataCommand } from './commands/historical-data' @@ -60,6 +61,7 @@ const bifravstCLI = async () => { generateCertCommand({ endpoint }), connectCommand({ endpoint, deviceUiUrl, certsDir }), reactConfigCommand({ stackId, region }), + infoCommand({ stackId, region }), cdCommand({ region }), historicalDataCommand({ region, diff --git a/cli/commands/info.ts b/cli/commands/info.ts new file mode 100644 index 00000000..1a268ae3 --- /dev/null +++ b/cli/commands/info.ts @@ -0,0 +1,36 @@ +import { ComandDefinition } from './CommandDefinition' +import { stackOutput } from '../cloudformation/stackOutput' +import chalk from 'chalk' + +export const infoCommand = ({ + stackId, + region, +}: { + stackId: string + region: string +}): ComandDefinition => ({ + command: 'info', + options: [ + { + flags: '-o, --output ', + description: 'If set, only return the value of this output', + }, + ], + action: async ({ output }) => { + const outputs = await stackOutput({ + stackId, + region, + }) + if (output) { + if (outputs[output] === undefined) { + throw new Error(`${output} is not defined.`) + } + console.log(outputs[output]) + return + } + Object.entries(outputs).forEach(([k, v]) => { + console.log(chalk.yellow(k), chalk.green(v)) + }) + }, + help: 'Prints information about your stack', +})