oclif / command

oclif base command

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[QUESTION] How to easily add styling to `this.log`

shaunwarman opened this issue · comments

I assume that a commands log mirrors console.log and that would mean that you can introduce styling and color. Is this correct?

Also, is it worth taking advantage of something like chalk so that users can just do: this.log('yellow', msg) or similar? Maybe this is better suited for cli-ux

You could overwrite log in a base class and add your stylings. If you wanted more of a helper, then agreed that cli-ux is probably the place for it.

You can pass format args to this.log, see

log(message = '', ...args: any[]) {
&& https://millermedeiros.github.io/mdoc/examples/node_api/doc/util.html#util.format.