Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
feat(cli): add info command
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Aug 26, 2019
1 parent 073de80 commit 5526764
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cli/bifravst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -60,6 +61,7 @@ const bifravstCLI = async () => {
generateCertCommand({ endpoint }),
connectCommand({ endpoint, deviceUiUrl, certsDir }),
reactConfigCommand({ stackId, region }),
infoCommand({ stackId, region }),
cdCommand({ region }),
historicalDataCommand({
region,
Expand Down
36 changes: 36 additions & 0 deletions cli/commands/info.ts
Original file line number Diff line number Diff line change
@@ -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 <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',
})

0 comments on commit 5526764

Please sign in to comment.