GithubHelp home page GithubHelp logo

concolor's People

Contributors

davide125 avatar epage avatar jcgruenhage avatar renovate[bot] avatar rumpuslabs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

concolor's Issues

Mixin docs shown as command help

When the app doesn't have any help documentation, the help output is showing Mixin a clap argument for colored output selection as the first line.

Given an app defined like this:

use clap::{CommandFactory, Parser};

#[derive(Parser)]
#[command(name = "foobar", color = concolor_clap::color_choice())]
struct Opt {
    #[clap(flatten)]
    pub color: concolor_clap::Color,
}

I expect the --help flag to output this:

$ cargo run --quiet -- --help
Usage: foobar [OPTIONS]

Options:
      --color <WHEN>  Controls when to use color [default: auto] [possible values: auto, always, never]
  -h, --help          Print help information

Instead, I'm getting this:

$ cargo run --quiet -- --help
Mixin a clap argument for colored output selection

Usage: foobar [OPTIONS]

Options:
      --color <WHEN>  Controls when to use color [default: auto] [possible values: auto, always, never]
  -h, --help          Print help information


Version Information

rustup --version --verbose:

rustc 1.66.0-nightly (f83e0266c 2022-10-03)
binary: rustc
commit-hash: f83e0266cf7aaa4b41505c49a5fd9c2363166522
commit-date: 2022-10-03
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.2
Crate Name Version
clap v4.0.9
concolor_clap v0.0.11

If this is the wrong place to submit this issue, let me know and I can move it. πŸ™‚

Deprecate concolor

concolor was intended as a way to be aware of the exact color situation for either stdout or stderr anywhere in an application, whether from environment detection or the command-line.

Through the time I've been using concolor, I've been feeling like this direction is a mistake. We instead need to be encouraging decoupling of rendering code from color control. To this end, I've created anstream which has been used in clap now for about three months.

For applications where anstream doesn't work, I feel like users would be better off composing what they need out of colorchoice, colorchoice-clap, and your choice of environment detection crates including anstyle-query and supports-color.

As I feel like both of these are a better route and that should cover all users, I don't see how concolor fits into the CLI story anymore and propose we deprecate it.

If nothing comes up before then, we'll likely archive the repo in about a month

Build failure on Windows + Rust 1.61.0

This Dependabot PR got opened against my repository: arxanas/git-branchless#851

The Windows build fails: https://github.com/arxanas/git-branchless/actions/runs/4412150004/jobs/7731338669

Error output
Run cargo build --all-targets --workspace
  cargo build --all-targets --workspace
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
  env:
    CARGO_INCREMENTAL: 0
    RUST_BACKTRACE: short
    CACHE_ON_FAILURE: false
    Updating crates.io index
Downloading crates ...
  Downloaded futures-core v0.3.27
  Downloaded futures-sink v0.3.27
  Downloaded futures-task v0.3.27
  Downloaded futures-macro v0.3.27
  Downloaded concolor-query v0.3.2
  Downloaded chrono v0.4.24
  Downloaded windows-targets v0.42.2
  Downloaded futures-io v0.3.27
  Downloaded futures-executor v0.3.27
  Downloaded futures-channel v0.3.27
  Downloaded concolor v0.1.1
  Downloaded async-trait v0.1.66
  Downloaded futures v0.3.27
  Downloaded futures-util v0.3.27
  Downloaded windows_x86_64_msvc v0.42.2
  Downloaded windows-sys v0.45.0
warning: output filename collision.
The example target `static_contents` in package `scm-record v0.1.0 (D:\a\git-branchless\git-branchless\scm-record)` has the same output filename as the example target `static_contents` in package `git-record v0.3.0 (D:\a\git-branchless\git-branchless\git-record)`.
Colliding filename is: D:\a\git-branchless\git-branchless\target\debug\examples\static_contents.exe
The targets should have unique names.
Consider changing their names to be unique or compiling them separately.
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/63[13](https://github.com/arxanas/git-branchless/actions/runs/4412150004/jobs/7731338669#step:5:14)>.
warning: output filename collision.
The example target `static_contents` in package `scm-record v0.1.0 (D:\a\git-branchless\git-branchless\scm-record)` has the same output filename as the example target `static_contents` in package `git-record v0.3.0 (D:\a\git-branchless\git-branchless\git-record)`.
Colliding filename is: D:\a\git-branchless\git-branchless\target\debug\examples\static_contents.pdb
The targets should have unique names.
Consider changing their names to be unique or compiling them separately.
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
   Compiling windows_x86_64_msvc v0.42.2
   Compiling futures-core v0.3.27
   Compiling futures-channel v0.3.27
   Compiling futures-task v0.3.27
   Compiling futures-util v0.3.27
   Compiling futures-sink v0.3.27
   Compiling futures-io v0.3.27
   Compiling async-trait v0.1.66
   Compiling windows-sys v0.42.0
   Compiling windows-targets v0.42.2
   Compiling windows-sys v0.45.0
   Compiling futures-macro v0.3.27
   Compiling chrono v0.4.24
   Compiling concolor-query v0.3.2
error[E0658]: use of unstable library feature 'io_safety'
 --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec8[23](https://github.com/arxanas/git-branchless/actions/runs/4412150004/jobs/7731338669#step:5:24)\concolor-query-0.3.2\src\windows.rs:3:9
  |
3 |     use std::os::windows::io::AsHandle;
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #87074 <https://github.com/rust-lang/rust/issues/87074> for more information

error[E0658]: use of unstable library feature 'io_safety'
  --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6[29](https://github.com/arxanas/git-branchless/actions/runs/4412150004/jobs/7731338669#step:5:30)9db9ec823\concolor-query-0.3.2\src\windows.rs:[36](https://github.com/arxanas/git-branchless/actions/runs/4412150004/jobs/7731338669#step:5:37):36
   |
36 |         let stdout_handle = stdout.as_handle();
   |                                    ^^^^^^^^^
   |
   = note: see issue #87074 <https://github.com/rust-lang/rust/issues/87074> for more information

error[E0658]: use of unstable library feature 'io_safety'
  --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\concolor-query-0.3.2\src\windows.rs:[39](https://github.com/arxanas/git-branchless/actions/runs/4412150004/jobs/7731338669#step:5:40):36
   |
39 |         let stderr_handle = stderr.as_handle();
   |                                    ^^^^^^^^^
   |
   = note: see issue #87074 <https://github.com/rust-lang/rust/issues/87074> for more information

For more information about this error, try `rustc --explain E06[58](https://github.com/arxanas/git-branchless/actions/runs/4412150004/jobs/7731338669#step:5:59)`.
error: could not compile `concolor-query` due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
Error: Process completed with exit code 1.

This might be intentional, but I don't see a note about an MSRV for Windows in the README.

User choice (--color never | --color always) has no effect?

When calling the program below with cargo run -- --color never help, the help text is still colored.

I would have expected that concolor_clap::color_choice() would have returned the user's desired choice.

When executing cargo run -- --color never add, I get:

Cli { color: Color { color: Never }, action: Add }
Always
use clap::Parser;

/// Checking that --color works
#[derive(Debug, clap::Parser)]
#[clap(color = concolor_clap::color_choice())]
struct Cli {
    #[command(flatten)]
    color: concolor_clap::Color,

    #[command(subcommand)]
    action: Action,
}

#[derive(Debug, clap::Subcommand)]
enum Action {
   Add,
   Remove,
}

fn main() {
    let cli = Cli::parse();
    println!("{:?}", cli);
    println!("{:?}", concolor_clap::color_choice());
}

Am I missing something?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

cargo
crates/clap/Cargo.toml
  • clap 4.0.0
crates/concolor/Cargo.toml
  • bitflags 1
  • is-terminal 0.4
crates/example/Cargo.toml
  • clap 4.0.0
crates/override/Cargo.toml
  • colorchoice 1.0.0
crates/query/Cargo.toml
  • windows-sys 0.48.0
github-actions
.github/workflows/audit.yml
  • actions/checkout v3
  • actions-rs/audit-check v1
  • actions/checkout v3
  • EmbarkStudios/cargo-deny-action v1
.github/workflows/ci.yml
  • actions/checkout v3
  • Swatinem/rust-cache v2
  • actions/checkout v3
  • Swatinem/rust-cache v2
  • actions/checkout v3
  • Swatinem/rust-cache v2
  • actions/checkout v3
  • Swatinem/rust-cache v2
  • actions/checkout v3
  • Swatinem/rust-cache v2
  • github/codeql-action v2
.github/workflows/committed.yml
  • actions/checkout v3
.github/workflows/pre-commit.yml
  • actions/checkout v3
  • actions/setup-python v4
  • pre-commit/action v3.0.0
.github/workflows/rust-next.yml
  • actions/checkout v3
  • Swatinem/rust-cache v2
.github/workflows/spelling.yml
  • actions/checkout v3
regex
.clippy.toml
  • rust 1.64.0
.github/workflows/ci.yml
  • rust 1.64.0
  • rust 1.64.0
  • rust 1.64.0
crates/clap/Cargo.toml
  • rust 1.64.0
crates/concolor/Cargo.toml
  • rust 1.64.0
crates/example/Cargo.toml
  • rust 1.64.0
crates/override/Cargo.toml
  • rust 1.64.0
crates/query/Cargo.toml
  • rust 1.64.0

  • Check this box to trigger a request for Renovate to run again on this repository

Programmatic `init()` with full detection, but without the Cargo feature?

Hi! concolor is really cool, and I want us to start using it! Unfortunately in our large buck2-managed monorepo cargo features are completely unified. This means internal libraries can't depend on a non-auto version without completely losing auto everywhere.

Would you consider exposing a way to programatically (re-)trigger detection as if the auto feature was enabled? That would let us integrate this in a central place used only in our CLIs, and keep the dependency default-features = false (and so safe to use in internal libraries, without fear of unintentionally "poisoning" builds).

(If you’re concerned about this undermining the intended usage of concolor, I think an approach like Tokio's unstable features could work here: https://docs.rs/tokio/latest/tokio/#unstable-features)

test failures with Rust 1.57

Hello, attempting to build [email protected] on Guix, I get the following test failure:

starting phase `check'
   Compiling concolor-control v0.0.7 (/tmp/guix-build-rust-concolor-control-0.0.7.drv-0/concolor-control-0.0.7)
    Finished test [unoptimized + debuginfo] target(s) in 0.21s
     Running unittests (target/debug/deps/concolor_control-862b70130982a923)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests concolor-control

running 2 tests
test src/lib.rs - (line 31) ... FAILED
test src/lib.rs - (line 62) ... ok

failures:

---- src/lib.rs - (line 31) stdout ----
error[E0425]: cannot find function `set` in crate `concolor_control`
  --> src/lib.rs:33:19
   |
5  | concolor_control::set(when);
   |                   ^^^ help: a function with a similar name exists: `get`
   |
  ::: /tmp/guix-build-rust-concolor-control-0.0.7.drv-0/concolor-control-0.0.7/src/no_color.rs:21:1
   |
21 | pub fn get(_stream: crate::Stream) -> Color {
   | ------------------------------------------- similarly named function `get` defined here

error: aborting due to previous error

For more information about this error, try `rustc --explain E0425`.
Couldn't compile the test.

failures:
    src/lib.rs - (line 31)

test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.15s

error: test failed, to rerun pass '--doc'
error: in phase 'check': uncaught exception:
%exception #<&invoke-error program: "cargo" arguments: ("test") exit-status: 101 term-signal: #f stop-signal: #f> 
phase `check' failed after 0.4 seconds

It is probably related the doctest problem (?) in Rust 1.57 that also causes xiph/rav1e#2851.

Is expected that older versions read different globals?

Hi, when I use a library that depends on v0.0.11 the global value that I set in my application has no effect. Only if the library also uses v0.1.0 (same as the binary) the globals are shared between the aplication and the library.

I tested this having 2 identical libs in a workspace with only this function. One with concolor v0.0.11 (or v0.0.12) and the other with v0.1.0.

pub fn has_color() -> bool {
    concolor::get(concolor::Stream::Stderr).color()
}

Then I call these functions from binary that depends on those libs and only the new version stays in sync. (I can upload a test repo but honestly it's just 10 lines of code)

Is this expected before 1.0? If so, it would be great to mention it in the readme to avoid confusion.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.