diff --git a/src/cli.ts b/src/cli.ts index 4247773..e962540 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,7 +1,7 @@ import { Command } from 'commander' import { readFileSync } from 'fs' import { run } from '~/shell' -import { exit, parseAndRemoveWildcardOptions } from '~/utils' +import { exit, parseAndRemoveWildcardOptions, pp } from '~/utils' import { StaxConfig } from '~/types' import Stax from '~/stax' import tmp from 'tmp' @@ -26,8 +26,7 @@ program.command('config') .description('Show config variables for the container.') .action((name, options) => { const container = stax.findContainer(name, options) - const attributes = { ...container.config, labels: container.labels } - console.log(attributes) + pp({ ...container.config, labels: container.labels }) }) program.command('copy') diff --git a/src/utils.ts b/src/utils.ts index 5d69563..e8e4256 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,6 +1,8 @@ import { existsSync, statSync } from 'fs' import tmp from 'tmp' import icons from './icons' +import yaml from 'js-yaml' +import chalk from 'chalk' // Parses a CSV string into a key/value object (e.g. "a=b,c=d" => { a: "b", c: "d" }) export function csvKeyValuePairs(csv: string = '') { @@ -106,3 +108,23 @@ export function getNonNullProperties(obj: Record): Record { + const match = line.match(/^(\s*)(\S+):(.*)$/) + if (match) { + const [, indent, key, value] = match + currentIndent = indent.length + const bar = chalk.gray('│ ').repeat(currentIndent / 2) + return `${bar}${chalk.cyan(key)}:${value}` + } else { + const bar = chalk.gray('│ ').repeat((currentIndent + 2) / 2) + return `${bar}${line.trim()}` + } + }) + console.log(coloredLines.slice(0, coloredLines.length-1).join('\n')) +}