Skip to content

--color option #145

Closed as duplicate
Closed as duplicate

Description

@raphael-proust

Currently, jbuilder seems to always output things in colour.

Many commands have a --color option which takes values always/yes, auto, never/no.

Could jbuilder have this option as well?

Activity

  1. UnixJunkie commented on Jun 23, 2017

    @UnixJunkie

    at least I like the default, we are in 2017 ...

  2. c-cube commented on Jun 25, 2017

    @c-cube

    Also it would be swell if jbuilder could call ocamlc/opt with the proper -color on more recent versions. I tried with flags but then it's not dependent on OCaml's version.

  3. basus commented on Jul 18, 2017

    @basus

    One kink is that the run action doesn't seem to preserve colored output for programs it runs. For example, I'm using the Alcotest library for tests which provides nicely colored output for errors, but the colors are discarded if I run the testing binary via jbuilder runtest.

  4. basus commented on Jul 19, 2017

    @basus

    @diml that seems to have worked. Thanks!

  5. added
    good first issue
    on Sep 21, 2018
  6. lubegasimon commented on Sep 15, 2020

    @lubegasimon
    Contributor

    @rgrinberg, @jeremiedimino , could anyone please add some pointer on this issue. Thank you.

  7. rgrinberg commented on Sep 15, 2020

    @rgrinberg
    Member

    Probably the easiest way to address this is using a global variable in Ansi_color. We just need a way to set term_supports_color if --color is passed. This doesn't seem so clean, so let's see if @jeremiedimino has another idea.

  8. lubegasimon commented on Sep 21, 2020

    @lubegasimon
    Contributor

    @rgrinberg, @jeremiedimino : Am sorry if am failing to figure out a simple, but allow me add my intuition here.
    Well, so as to know the color of the output of the program dune is running, we need to extract it from some file foo, pattern match on it against dune specific colors, then we tag the matched color in dune output.

    So if my intuition here is correct, then I think I need more info on how to access file foo.

  9. rgrinberg commented on Sep 22, 2020

    @rgrinberg
    Member

    Let me first clarify how dune handles colors today:

    • To enable/disable colors in the programs that dune launches (opam, ocaml), dune uses environment variables. See Colors.setup_env_for_colors.

    • To write color output, dune creates User_message.t values with appropriate styling that are eventually transformed to ansi escape sequences. This conversion is done in Colors.setup_err_formatter_colors

    Both of thse code paths fucntion if dune detects that the terminal supports colors. We'd like to create an additional condition for this support to be enabled: whether the user requested colors or not.

  10. added
    cli
    and removed on Jan 28, 2025
  11. added theissue type on Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

cligood first issue

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions