Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raw output option #271

Closed
T145 opened this issue Jun 25, 2021 · 13 comments
Closed

Raw output option #271

T145 opened this issue Jun 25, 2021 · 13 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@T145
Copy link

T145 commented Jun 25, 2021

Instead of #268, have a raw option to generate output that doesn't include emoji and the process indicator. This will help the results be piped into other programs like jq that people can then use to transform into JSON on their own. It could look like:

./lychee README.md --raw -v
@lebensterben
Copy link
Member

This is a good point.
Rust programmers are used to UTF compatibility but in reality other components in the toolchain may not be UTF compatible.

Meanwhile, if you can tell lychee to output results in JSON format. That's friendlier for jq.

@mre
Copy link
Member

mre commented Apr 25, 2022

This should work in master now to get raw output:

./lychee README.md --format=raw --no-progress -v

The NO_COLOR environment variable is also respected.
See #599 for details.

@mre
Copy link
Member

mre commented Apr 25, 2022

Gonna close this as resolved. Feel free to reopen if it doesn't work as expected.

@mre mre closed this as completed Apr 25, 2022
@alexanderbazhenoff
Copy link

Just wanna know how to enable colors in GitLab CI console? No info in README.

@mre
Copy link
Member

mre commented Apr 3, 2024

Sorry for the late reply.
You can try to set the NO_COLOR=1 environment variable, so

export NO_COLOR=1
lychee ...

or

NO_COLOR=1 lychee ...

@alexanderbazhenoff
Copy link

Sorry for the late reply. You can try to set the NO_COLOR=1 environment variable, so

No problem, but I meant enable colors :) Anyway neither NO_COLOR=0 (and NO_COLOR=false), nor NO_COLOR=1 (and NO_COLOR=true) got color changes in my GitLab CI, it's stll b/w. Using lychee-v0.14.3-aarch64-unknown-linux-gnu.tar.gz:

  script:
    - NO_COLOR=0 lychee -n .

lychee_bw

Any ideas?

mre added a commit that referenced this issue Apr 4, 2024
This adds support for formatting responses in different ways.
For now the options are
* `plain`: No color, basic formatting
* `color`: Color, indented formatting (default)
* `emoji`: Fancy mode with emoji icons

Fixes #546
Related to #271
@mre
Copy link
Member

mre commented Apr 4, 2024

@alexanderbazhenoff, I took a stab at it here: #1398
If you want, you can try it out by installing the version from that branch. I'd appreciate some feedback.

@mre mre reopened this Apr 4, 2024
mre added a commit that referenced this issue Apr 4, 2024
This adds support for formatting responses in different ways.
For now the options are
* `plain`: No color, basic formatting
* `color`: Color, indented formatting (default)
* `emoji`: Fancy mode with emoji icons

Fixes #546
Related to #271
mre added a commit that referenced this issue Apr 4, 2024
This adds support for formatting responses in different ways.
For now the options are
* `plain`: No color, basic formatting
* `color`: Color, indented formatting (default)
* `emoji`: Fancy mode with emoji icons

Fixes #546
Related to #271
mre added a commit that referenced this issue Apr 4, 2024
This adds support for formatting responses in different ways.
For now the options are
* `plain`: No color, basic formatting
* `color`: Color, indented formatting (default)
* `emoji`: Fancy mode with emoji icons

Fixes #546
Related to #271
@alexanderbazhenoff
Copy link

alexanderbazhenoff commented Apr 10, 2024

@alexanderbazhenoff, I took a stab at it here: #1398 If you want, you can try it out by installing the version from that branch. I'd appreciate some feedback.

Sorry for long reply.

I have placed a new binary alongside with an old, but named them as lychee2. So, -n --mode emoji worked as described behind, defaults still no color:

lychee-new

Runing the same defaults locally via console is nice and colored anyway:

lychee-local

No additional env variables set like COLOR/NO_COLOR in GitLab CI, just raw command run:

script:
  - lychee2 .

What I did wrong in my CI? Or what debug info from me is required?

@mre
Copy link
Member

mre commented Apr 15, 2024

I think the issue is on my end. Need to make more changes in the pull request. Apologies for the noise.

mre added a commit that referenced this issue Jun 14, 2024
This adds support for formatting responses in different ways.
For now the options are
* `plain`: No color, basic formatting
* `color`: Color, indented formatting (default)
* `emoji`: Fancy mode with emoji icons

Fixes #546
Related to #271
mre added a commit that referenced this issue Jun 14, 2024
This adds support for formatting responses in different ways.

For now, the options are:

* `plain`: No color, basic formatting
* `color`: Color, indented formatting (default)
* `emoji`: Fancy mode with emoji icons

Fixes #546
Related to #271
@adoyle-h
Copy link

adoyle-h commented Sep 1, 2024

I think it should be always trim colors for output file. NO_COLOR=1 is a redundant option. Who need the terminal color codes included in file?

@alexanderbazhenoff
Copy link

I think it should be always trim colors for output file. NO_COLOR=1 is a redundant option. Who need the terminal color codes included in file?

In this way COLORS=1 will be apprectiated :)
In practice, colors/emojis have become more readable in GitLab or other CI platforms output. Not everyone wants to aggregate CI logs outside of GitLab, but b/w as defaults is also ok.

@mre
Copy link
Member

mre commented Oct 8, 2024

With #1398 being merged, I think we can close this.

To recap, the main request for a raw output option has been implemented with --format=raw --no-progress.

There's an ongoing discussion about color output in CI environments, particularly GitLab CI:
The NO_COLOR environment variable doesn't seem to be working as expected over there?
Maybe it's already been resolved by now, either on the GitLab side or on lychee's side after merging #1398?
Either way, if someone finds the time, please investigate why NO_COLOR isn't working as expected in GitLab CI and create a new issue if needed.

@mre mre closed this as completed Oct 8, 2024
@mre
Copy link
Member

mre commented Oct 8, 2024

I've also documented the output modes on the documentation website here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants