Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit 00f2913

Browse files
committed
feat: added styledHeader and styledJSON
1 parent c2995ab commit 00f2913

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"@dxcli/screen": "^0.0.0",
99
"@heroku/linewrap": "^1.0.0",
1010
"ansi-styles": "^3.2.0",
11+
"cardinal": "^1.0.0",
1112
"chalk": "^2.3.0",
1213
"fs-extra": "^5.0.0",
1314
"lodash": "^4.17.4",

src/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ export class CLI {
5858

5959
styledObject(...args: any[]) { require('./styled/object').default(...args) }
6060
table(...args: any[]) { (require('./styled/table'))(...args) }
61+
styledJSON(obj: any) {
62+
let json = JSON.stringify(obj, null, 2)
63+
if (!deps.chalk.enabled) {
64+
this.log(json)
65+
return
66+
}
67+
let cardinal = require('cardinal')
68+
let theme = require('cardinal/themes/jq')
69+
this.log(cardinal.highlight(json, {json: true, theme}))
70+
}
71+
72+
styledHeader(header: string) {
73+
this.log(deps.chalk.dim('=== ') + deps.chalk.bold(header))
74+
}
6175

6276
prompt(name: string, options: IPromptOptions = {}) {
6377
return this.action.pauseAsync(() => {

0 commit comments

Comments
 (0)