Skip to content

the lint command should omit coloring intelligently #29

@VladimirAlexiev

Description

@VladimirAlexiev

Consider the ugly ANSI escapes below:

jsonld lint -l  FI2.jsonld |less
WARNING: Relative @type reference found.
{
  type: [ ESC[32m'JsonLdEvent'ESC[39m ],
  code: ESC[32m'relative @type reference'ESC[39m,
  level: ESC[32m'warning'ESC[39m,
  message: ESC[32m'Relative @type reference found.'ESC[39m,
  details: { type: ESC[32m'$id'ESC[39m }
}
...

Why did I pipe it through less instead of enjoying the nice coloring at the terminal?

Because for this file I get 79 errors like this:

jsonld lint -l  FI2.jsonld |sort|uniq -c
     79   code: 'relative @type reference',
     79   details: { type: '$id' }
     79   level: 'warning',
     79   message: 'Relative @type reference found.',
     79   type: [ 'JsonLdEvent' ],
     79 {
     79 }
     79 WARNING: Relative @type reference found.

And because quite often I want to save the output of lint to a file to share with colleagues.

So lint should inspect its STDOUT and use coloring only if it's an interactive terminal.
Or have an option to omit coloring.

Version:

jsonld -V
2.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions