Stream: general

Topic: termcolor


Josh Triplett (May 03 2020 at 21:02, on Zulip):

@pksunkara Other than cleaner and more maintained Windows support, what are the advantages of termcolor over ansi_term?

pksunkara (May 03 2020 at 21:03, on Zulip):

It had buffered support, which while not important to clap is a good feature for threading

pksunkara (May 03 2020 at 21:03, on Zulip):

Also does console

pksunkara (May 03 2020 at 21:03, on Zulip):

But console's windows coloring in non-ansi supported is lazy and might have degraded perf

Josh Triplett (May 03 2020 at 21:05, on Zulip):

That's what I was wondering. I think there's value in the forward-looking approach of "color on systems that support ANSI, correct monochrome behavior otherwise".

Josh Triplett (May 03 2020 at 21:05, on Zulip):

What do you mean by "buffered support"?

pksunkara (May 03 2020 at 21:06, on Zulip):

There 2 kinds of windows, 1 where ANSI is support, the other where ANSI is not but we have windows console API

pksunkara (May 03 2020 at 21:06, on Zulip):

To do colors on windows console API, we need to call a set of commands while printing output

Josh Triplett (May 03 2020 at 21:06, on Zulip):

Yeah, I'm familiar with that.

Josh Triplett (May 03 2020 at 21:07, on Zulip):

Windows 10 is where you can start assuming ANSI color mode, right? (Modulo needing to turn it on at program startup.)

pksunkara (May 03 2020 at 21:07, on Zulip):

I think so, not completely sure about where it starts

pksunkara (May 03 2020 at 21:07, on Zulip):

Termcolor stores the commands and output data in an internal struct

pksunkara (May 03 2020 at 21:07, on Zulip):

And using this, you can store buffers of these outputs+commands

Josh Triplett (May 03 2020 at 21:08, on Zulip):

That was always what I found most inconvenient about using some of the other color APIs.

Josh Triplett (May 03 2020 at 21:08, on Zulip):

The whole "you can't just print this" problem. :)

pksunkara (May 03 2020 at 21:08, on Zulip):

and do it in a thread separate approach

pksunkara (May 03 2020 at 21:09, on Zulip):

In console whose windows console fix I implement just last week, you treat everything as ANSI string

Josh Triplett (May 03 2020 at 21:09, on Zulip):

Interesting!

Josh Triplett (May 03 2020 at 21:09, on Zulip):

You're translating for older Windows?

pksunkara (May 03 2020 at 21:09, on Zulip):

But when there is only windows console API, while priting the ANSI string, console strips the ansi tags and sends color commands when it sees an ansi tag

pksunkara (May 03 2020 at 21:09, on Zulip):

I already finished

pksunkara (May 03 2020 at 21:10, on Zulip):

https://github.com/mitsuhiko/console

Josh Triplett (May 03 2020 at 21:10, on Zulip):

(I meant "translating" the sequences at runtime, not "currently working on translating the code".)

pksunkara (May 03 2020 at 21:10, on Zulip):

Yes

pksunkara (May 03 2020 at 21:11, on Zulip):

https://github.com/mitsuhiko/console/commit/20c740f69dfb948de8530e228c8772b7c9a06816#diff-cf150a986c7ff2904842507b477dc0b1R386

Josh Triplett (May 03 2020 at 21:11, on Zulip):

That's a really nice approach.

Josh Triplett (May 03 2020 at 21:11, on Zulip):

I imagine it was a pain to implement, but that seems very clean.

pksunkara (May 03 2020 at 21:11, on Zulip):

Yeah, thought it would be difficult but wasn't

Josh Triplett (May 03 2020 at 21:11, on Zulip):

Does the old Windows console support allow RGB colors?

pksunkara (May 03 2020 at 21:12, on Zulip):

Don't think so. I was looking at termcolor's code related to this

Josh Triplett (May 03 2020 at 21:12, on Zulip):

Unfortunate, but not an unreasonable limitation.

pksunkara (May 03 2020 at 21:13, on Zulip):

https://github.com/BurntSushi/termcolor/blob/master/src/lib.rs#L1820

pksunkara (May 03 2020 at 21:14, on Zulip):

https://github.com/BurntSushi/termcolor/blob/master/src/lib.rs#L1788 is the function which translates to windows console

Josh Triplett (May 03 2020 at 21:15, on Zulip):

So, I'm currently working with the author of ansi_term, to step up maintenance of it, with the hopes of moving to a 1.0 version.

Josh Triplett (May 03 2020 at 21:15, on Zulip):

I'm wondering if there might be value in trying to do some unification, such as at the very least, having a common set of types for things like colors and text styles.

Josh Triplett (May 03 2020 at 21:16, on Zulip):

I'm not suggesting unifying the higher-level code, but it'd be nice if crates like my colorparse could translate to one uniform type and then use that type with any of these crates.

Josh Triplett (May 03 2020 at 21:16, on Zulip):

Right now, colorparse translates directly to ansi_term::Style objects.

Josh Triplett (May 03 2020 at 21:17, on Zulip):

Might it make sense to have an ansi-style-common crate or similar?

pksunkara (May 03 2020 at 21:17, on Zulip):

Only for the color & style enums?

Josh Triplett (May 03 2020 at 21:18, on Zulip):

If there might be value in others, we could do those too, but my first thought was a common type vocabulary for things like "bold, blue, underlined, hyperlinked to this URL".

pksunkara (May 03 2020 at 21:19, on Zulip):

https://docs.rs/termcolor/1.1.0/termcolor/enum.Color.html

pksunkara (May 03 2020 at 21:19, on Zulip):

https://docs.rs/console/0.11.2/console/enum.Color.html

Josh Triplett (May 03 2020 at 21:19, on Zulip):

Right, that for color, and then a concept of styled text: foreground color, background color,the various attributes...

pksunkara (May 03 2020 at 21:20, on Zulip):

I understand where you are coming from

Josh Triplett (May 03 2020 at 21:20, on Zulip):

https://docs.rs/ansi_term/0.12.1/ansi_term/struct.Style.html

pksunkara (May 03 2020 at 21:20, on Zulip):

But I am not sure whether this would be a good idea or not

Josh Triplett (May 03 2020 at 21:21, on Zulip):

I'm not sure either, but I think it's worth discussing, especially before ansi_term does a major API bump to 1.0.

Josh Triplett (May 03 2020 at 21:21, on Zulip):

I'm certainly willing to factor out and share types.

pksunkara (May 03 2020 at 21:21, on Zulip):

Yeah, definitely

Josh Triplett (May 03 2020 at 21:21, on Zulip):

So, a different question...

Josh Triplett (May 03 2020 at 21:21, on Zulip):

Does wg-cli have an organization to maintain some of its crates in common?

pksunkara (May 03 2020 at 21:21, on Zulip):

console has a style builder pattern. https://docs.rs/console/0.11.2/console/struct.Style.html

Josh Triplett (May 03 2020 at 21:22, on Zulip):

Or are they kept in various different places?

pksunkara (May 03 2020 at 21:22, on Zulip):

https://github.com/rust-cli

Josh Triplett (May 03 2020 at 21:22, on Zulip):

Yeah, ansi_term has a similar builder pattern, and we're also thinking of adding a style! macro: style![bold blue on(green)] or something.

pksunkara (May 03 2020 at 21:23, on Zulip):

Regarding the common crate, let's go ahead and start the discussion, but let's also involve BurntSushi by creating this discussion on termcolor repo

Josh Triplett (May 03 2020 at 21:23, on Zulip):

:+1:

pksunkara (May 03 2020 at 21:23, on Zulip):

And rust-cli group is also trying not to bless anything

Josh Triplett (May 03 2020 at 21:23, on Zulip):

Absolutely understood and agreed.

Josh Triplett (May 03 2020 at 21:24, on Zulip):

That leads into my next question: do you think it makes sense for crates like ansi_term to seek a home in the rust-cli org, or do you think that they should live in a separate org of their own?

Josh Triplett (May 03 2020 at 21:24, on Zulip):

Or might that depend on the outcome of this discussion about common infrastructure/type crates?

pksunkara (May 03 2020 at 21:25, on Zulip):

There are definitely different approaches for this coloring problem

pksunkara (May 03 2020 at 21:25, on Zulip):

So, definitely different crates

pksunkara (May 03 2020 at 21:25, on Zulip):

But I think the common type create if we create it can live in rust-cli

Josh Triplett (May 03 2020 at 21:25, on Zulip):

/me agrees that it doesn't make sense to try to merge the crates themselves.

Josh Triplett (May 03 2020 at 21:25, on Zulip):

Ah, I see what you meant.

Josh Triplett (May 03 2020 at 21:25, on Zulip):

I was actually wondering if it would make sense for multiple color/style crates to coexist in wg-cli. :)

Josh Triplett (May 03 2020 at 21:26, on Zulip):

But if you think the right answer is "none of them", that makes sense too.

pksunkara (May 03 2020 at 21:26, on Zulip):

Yeah, I am leaning towards none of them except the common stuff

Josh Triplett (May 03 2020 at 21:26, on Zulip):

I can start the discussion on a termcolor issue; I've got some additional things to add regarding the contents of the Style type.

Josh Triplett (May 03 2020 at 21:27, on Zulip):

Should I CC you on the issue?

pksunkara (May 03 2020 at 21:28, on Zulip):

Please do. Thanks. Same username on github as here

Josh Triplett (May 03 2020 at 21:29, on Zulip):

Thanks!

Josh Triplett (May 03 2020 at 21:40, on Zulip):

https://github.com/BurntSushi/termcolor/issues/29

Charles Lew (May 04 2020 at 17:39, on Zulip):

There's also
colored: https://docs.rs/colored
term: https://docs.rs/term

Charles Lew (May 04 2020 at 17:40, on Zulip):

And don't forget there is a in-tree one term that is shipped and used by all unit tests : (

DPC (May 05 2020 at 00:32, on Zulip):

@Josh Triplett hi. one of the core cli-wg people here. (Sorry i didn't see this because i generally don't check #general, will reply in a while )

DPC (May 05 2020 at 00:51, on Zulip):

also yes, if you can't maintain it, we can take it under the rust-cli umbrella

Josh Triplett (May 05 2020 at 01:49, on Zulip):

It's not a matter of "can't maintain it", it's more that I'd like it to have an organizational home with others who may be interested.

Josh Triplett (May 05 2020 at 01:50, on Zulip):

@DPC I'd be happy to help with maintenance, and the original author still wants to work on it as well, but we'd love to have it in a common org.

pksunkara (May 05 2020 at 09:44, on Zulip):

As I said before rust-cli is probably not the right org for any of the coloring crates because there exists many architectural approaches and cli-wg should not bless one of those.

DPC (May 05 2020 at 10:25, on Zulip):

Please do not speak for the organization

pksunkara (May 05 2020 at 18:53, on Zulip):

I didn't mean it like that. It is my opinion as stated before.

Josh Triplett (May 05 2020 at 19:42, on Zulip):

I really don't want to get into a policy dispute here. I do need to find a home for ansi_term. If there's consensus that rust-cli is a good home for it, I'd be happy to have it there. If there's not such a consensus, I don't want to get into the middle of anything.

spacekookie (May 05 2020 at 20:30, on Zulip):

I think that cli-wg would be a really good fit, especially because it's been morphing into a general lib/ application support group. We're working on crash reporting, language and translation tools, packaging tools, etc. Handling term colours would fit into that general group

nagisa (May 05 2020 at 20:46, on Zulip):

Maintaining a crate under a wg umbrella does not really signal its blessing, the way I see it, though I can see why other people might interpret it as such.

nagisa (May 05 2020 at 20:47, on Zulip):

I generally still trust recommendations and usage numbers more when picking out a crate from multiple options for some task.

spacekookie (May 05 2020 at 20:51, on Zulip):

nagisa said:

Maintaining a crate under a wg umbrella does not really signal its blessing, the way I see it, though I can see why other people might interpret it as such.

Especially the embedded-wg has been setting a good precedence for this. It's of course no replacement for actual work hours put into the project: if the WG doesn't have enough people doing work across all the crates, it's kinda useless. But at the very least it might make it easier for interested people to join the group of maintainers

DPC (May 05 2020 at 22:56, on Zulip):

we undertook crates like clap and paw under the wg, so i don't see what's wrong with this one

DPC (May 05 2020 at 22:58, on Zulip):

we had a discussion in november where we decided to support other crates and take them under the working group umbrella and this one should fall under that criteria

Lokathor (May 06 2020 at 00:31, on Zulip):

(If possible, I'd actually like a broader discussion in what a WG maintaining a crate "means" because it's also come up as a question in the gamedev-wg. I'd like if someone could help set the general WG policy there, or at least the default policy, and maybe we could write that down in wherever we describe how WGs work.)
(where to push such a discussion, I don't actually know)

Charles Lew (May 06 2020 at 05:09, on Zulip):

Maybe a topic of wg-governance.

Josh Triplett (May 06 2020 at 06:03, on Zulip):

@DPC If I would like to add the crate, what would be the next step?

pksunkara (May 06 2020 at 06:32, on Zulip):

we undertook crates like clap and paw under the wg, so i don't see what's wrong with this one

But 2 months ago, there was a consensus in the cli-wg meetings to go back on clap related crates. The reason is to say they do not want to bless any specific crate unless it is the only existing crate of that nature. I wouldn't say ansi_term qualifies for it.

pksunkara (May 06 2020 at 06:38, on Zulip):

I am not sure, but I think the next steps might be to propose this for next cli-wg meeting?

spacekookie (May 06 2020 at 07:58, on Zulip):

pksunkara said:

we undertook crates like clap and paw under the wg, so i don't see what's wrong with this one

But 2 months ago, there was a consensus in the cli-wg meetings to go back on clap related crates. The reason is to say they do not want to bless any specific crate unless it is the only existing crate of that nature. I wouldn't say ansi_term qualifies for it.

I think this has to be something that's decided on a crate by crate basis, but I also think that clap is a bit special in this regards because the project is quite big and opinionated, and it's about not picking winners in a space where there's many viable candidates.

That doesn't mean that we can't or won't maintain other crates.

spacekookie (May 06 2020 at 07:59, on Zulip):

Proposing it to the cli-wg would definitely be the next step. @Josh Triplett wanna e-mail cli-wgf@rust-lang.org? That's the official talk channel

Josh Triplett (May 06 2020 at 16:17, on Zulip):

@spacekookie Is that f supposed to be in the email, or is it cli-wg@ ?

DPC (May 06 2020 at 17:25, on Zulip):

ther'es no f

spacekookie (May 06 2020 at 18:49, on Zulip):

Woops, yea that's a typo!

Last update: May 29 2020 at 17:00UTC