rust-lang / rustfmt

Format Rust code
https://rust-lang.github.io/rustfmt/
Apache License 2.0
6.06k stars 892 forks source link

[unstable option] color #3385

Open scampi opened 5 years ago

scampi commented 5 years ago

Tracking issue for color

topecongiro commented 4 years ago

Will be removed in 2.0.

karyon commented 3 years ago

This was removed in 2.x in https://github.com/rust-lang/rustfmt/pull/4006, but needs to be re-decided in 1.x.

lnshi commented 3 years ago

With github actions, even with --color=always still the diff view is NOT colourful:

runs-on: ubuntu-latest
steps:
  - uses: actions-rs/toolchain@v1
    with:
      toolchain: stable
      override: true

  - uses: actions/checkout@v2

  - name: Test run bare cargo fmt
    run: >
      cargo fmt --all --manifest-path=rsmain/Cargo.toml
      -- --check --color=always
calebcartwright commented 3 years ago

With github actions, even with --color=always still the diff view is NOT colourful:

That's because Actions has issues reporting tty/color support which has impacted myriad tools (https://github.com/actions/runner/issues/241). Some tools have implemented GitHub Actions-specific workarounds for this (e.g. by checking for the presence of the Actions-set env var), but I don't think that really makes sense for us. We utilize the term crate for detection and handling, so if that's something important to you then I'd suggest reaching out to them (https://github.com/Stebalien/term) to gauge their willingness/interest in supporting any such workaround for GHA.

francisdb commented 1 year ago

Just a note. Cargo has CARGO_TERM_COLOR env var that can be set to always for colors on github ci. But cargo fmt is not using that.