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

ANSI styled error messages #144

Open
dbuenzli opened this issue Mar 19, 2022 · 1 comment
Open

ANSI styled error messages #144

dbuenzli opened this issue Mar 19, 2022 · 1 comment

Comments

@dbuenzli
Copy link
Owner

Since isatty seems to be bound to make it in the stdlib (ocaml/ocaml#11128), I'm willing to use caml_sys_tty primitive (available since this ocaml/ocaml@a69e3e3 which went into 4.03).

Nothing fancy except turning quoted material into bold.

A few things would need to be sorted out though, e.g. how to control it via a default option (mandatory or not) and interaction with existing user options like Fmt_cli provides that do the same.

I guess people are going to mention the NO_COLOR environment variable but it's a rather stupid standard, this comment explains it well.

@dbuenzli
Copy link
Owner Author

In fact in general I'm no longer convinced by isatty being a good signal to inform the default behaviour for styling. isatty is false when you page a program's output. But it's often good to have colors in this case; like most git diff users will likely agree with by now.

In any case for cmdliner this is not going to be fancy. We just want to use bold for quoting and perhaps a red for highlighting errors. It is also always only be used for reporting command line errors, so I don't think it needs to be more sophisticated than this:

  1. Use ANSI styles unconditionally except if TERM is dumb or unset (the latter is true in browser consoles but I don't expect cmdliner error messages to show up in browser consoles).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant