Jump to page: 1 2 3
Thread overview
DUB colored output proposal/showcase
Jun 08, 2018
gdelazzari
Jun 08, 2018
gdelazzari
Jun 08, 2018
Uknown
Jun 08, 2018
gdelazzari
Jun 08, 2018
Jacob Carlborg
Jun 19, 2018
Guillaume Piolat
Jun 08, 2018
Jacob Carlborg
Jun 08, 2018
gdelazzari
Jun 08, 2018
gdelazzari
Jun 19, 2018
Jacob Carlborg
Jun 19, 2018
Anton Fediushin
Jun 08, 2018
Atila Neves
Jun 08, 2018
Bastiaan Veelo
Jun 08, 2018
Johannes Loher
Jun 08, 2018
Basile B.
Jun 08, 2018
gdelazzari
Jun 08, 2018
Basile B.
Jun 08, 2018
gdelazzari
Jun 09, 2018
Nick Sabalausky
Jun 09, 2018
gdelazzari
June 08, 2018
Hello everyone, I'm a new user of the language (I've been playing around with it for some months) and I'm really liking it.

One minor thing that I didn't particularly like was what (and how) DUB spits out stuff to the terminal, in the sense that I find the output a bit difficult to navigate i.e. I can't easily understand, at a first glance, what's going on. Given that I tried various languages recently, including their package manager, and seeing how much clearer their output was, I think DUB could also be improved in the same way. The main thing that would make the output clearer would be to color the output and format it a bit better, IMHO. It would also look way prettier.

Given that this seemed like an easy task, I already implemented a proof-of-concept just to see how that would look like and, in my opinion, now it's really clear what's going on. Take a look at these screenshots:

https://imgur.com/a/3RJyd6m

Some of you will have already noticed... Yes, I got really inspired by Rust's "Cargo" package manager, but not because I'm a Rust fanboy or something like that (I don't even particularly like it as a language), but just because of all the package managers I tried, Rust's one has been the simplest, cleanest, approachable and immediate I've ever seen. The way Cargo organizes and colors the stuff it prints seemed like a really good approach, so I thought implementing a similar thing (with some changes/twists) would be a good starting point. Of course I'm totally open to suggestions and I don't even want Dub to look exactly like Cargo, at all. However the concept of a colored "tag" at the beginning of the line looks really cool and useful in my opinion. All the green tags are related to the building process, so when your eyes see green you know it's compiling/linking, while package fetching/upgrading/etc... stuff has a yellow tag, so you immediately know Dub is doing package related things just by seeing yellow text. There are other minor changes, like removing the three dots "..." after every line (which, IMHO, just clutter the output) and other things.

As I said, this is just a proposal, and I will happily take any feedback, critiques, enhancements, etc... I also hope this won't offend anyone, both because I want to change Dub and because I got inspired by the package manger of a competitor language.

I started this thread to have a discussion on this before submitting any pull request (which, in the case of this change being apprecciated, I'll happily take the time to make).

Thanks to anyone in advance,
Giacomo
June 08, 2018
On 6/8/18 9:35 AM, gdelazzari wrote:
> Hello everyone, I'm a new user of the language (I've been playing around with it for some months) and I'm really liking it.
> 
> One minor thing that I didn't particularly like was what (and how) DUB spits out stuff to the terminal, in the sense that I find the output a bit difficult to navigate i.e. I can't easily understand, at a first glance, what's going on. Given that I tried various languages recently, including their package manager, and seeing how much clearer their output was, I think DUB could also be improved in the same way. The main thing that would make the output clearer would be to color the output and format it a bit better, IMHO. It would also look way prettier.
> 
> Given that this seemed like an easy task, I already implemented a proof-of-concept just to see how that would look like and, in my opinion, now it's really clear what's going on. Take a look at these screenshots:
> 
> https://imgur.com/a/3RJyd6m

Looks excellent! Two thumbs up from me. Is it cross-platform?

Note on some platforms (ahem, Macos) the background is white, so this should be correctly colored for that possibility.

-Steve
June 08, 2018
On Friday, 8 June 2018 at 13:38:59 UTC, Steven Schveighoffer wrote:
> Looks excellent! Two thumbs up from me. Is it cross-platform?
>
> Note on some platforms (ahem, Macos) the background is white, so this should be correctly colored for that possibility.
>
> -Steve

At the moment it's "probably" Linux-only, but that's because I only wanted a proof of concept and I worked on it on my Linux installation. I imported this library/Dub package https://github.com/yamadapc/d-colorize and just used it. Which, by the way, it's no-good at the moment since I saw that Dub doesn't use Dub packages itself - probably because, otherwise, you don't have a way to easily compile it without Dub itself, I guess :P so I'll need to either write my custom color outputting code within Dub's source or just import that library.

Of course making it cross-platform is a mandatory thing to me. Windows also needs some specific stuff to output colors, as you can see in the library I linked, so there are definitely some things to do to support all the platforms. I may even take a look at how DMD itself outputs colored output, I guess it will be nice to keeps things consistent.

As for MacOS having a different background... I don't really own a Mac nor I have ever used one before, so I don't even know how tools usually output their colored text on it. At the moment it just sets the foreground color to green/yellow/blue/whatever, without changing the background, if that was your concern. If you meant that yellow-on-white is not readable... well... I guess so. Maybe two different color palettes should be used? IDK, as I said I never used a Mac before so I don't really know how other tools handle this, maybe if some Mac user could help on this, it would be great.

Thanks for the appreciation by the way!
June 08, 2018
On Friday, 8 June 2018 at 13:35:36 UTC, gdelazzari wrote:
> Hello everyone, I'm a new user of the language (I've been playing around with it for some months) and I'm really liking it.
>
> [...]

I like it!

Atila
June 08, 2018
On 6/8/18 9:51 AM, gdelazzari wrote:
> On Friday, 8 June 2018 at 13:38:59 UTC, Steven Schveighoffer wrote:
>> Looks excellent! Two thumbs up from me. Is it cross-platform?
>>
>> Note on some platforms (ahem, Macos) the background is white, so this should be correctly colored for that possibility.
>>
> 
> At the moment it's "probably" Linux-only, but that's because I only wanted a proof of concept and I worked on it on my Linux installation. I imported this library/Dub package https://github.com/yamadapc/d-colorize and just used it. Which, by the way, it's no-good at the moment since I saw that Dub doesn't use Dub packages itself - probably because, otherwise, you don't have a way to easily compile it without Dub itself, I guess :P so I'll need to either write my custom color outputting code within Dub's source or just import that library.

Yeah, I would expect that the colorization is simply a matter of outputting the right control characters. You probably just need to include some simple stuff inside dub source itself. But I'm far from experienced on this.

> 
> Of course making it cross-platform is a mandatory thing to me. Windows also needs some specific stuff to output colors, as you can see in the library I linked, so there are definitely some things to do to support all the platforms. I may even take a look at how DMD itself outputs colored output, I guess it will be nice to keeps things consistent.
> 
> As for MacOS having a different background... I don't really own a Mac nor I have ever used one before, so I don't even know how tools usually output their colored text on it. 

I'm assuming it's similar to Linux, it's just that the background is white instead of black.

>At the moment it just sets the 
> foreground color to green/yellow/blue/whatever, without changing the background, if that was your concern. If you meant that yellow-on-white is not readable... well... I guess so.

Yes. In fact, I've used the new vibe.d and it appears not to adjust its colorization to my screen, it's light grey on white (almost impossible to read).

> Maybe two different color palettes should be used? IDK, as I said I never used a Mac before so I don't really know how other tools handle this, maybe if some Mac user could help on this, it would be great.

The way I would solve it is to have a "light" mode and a "dark" mode, and version the default mode based on the OS (Linux, windows, etc. all dark mode by default, macos light mode by default).

> 
> Thanks for the appreciation by the way!

Thanks for the effort!

-Steve
June 08, 2018
On Friday, 8 June 2018 at 13:35:36 UTC, gdelazzari wrote:
> Hello everyone, I'm a new user of the language (I've been playing around with it for some months) and I'm really liking it.
[...]
> Take a look at these screenshots:
>
> https://imgur.com/a/3RJyd6m

Nice!!




June 08, 2018
On Friday, 8 June 2018 at 13:51:05 UTC, gdelazzari wrote:
> On Friday, 8 June 2018 at 13:38:59 UTC, Steven Schveighoffer wrote:
>> Looks excellent! Two thumbs up from me. Is it cross-platform?
>>
>> Note on some platforms (ahem, Macos) the background is white, so this should be correctly colored for that possibility.
>>
>> -Steve
>
> At the moment it's "probably" Linux-only, but that's because I only wanted a proof of concept and I worked on it on my Linux installation. I imported this library/Dub package https://github.com/yamadapc/d-colorize and just used it. Which, by the way, it's no-good at the moment since I saw that Dub doesn't use Dub packages itself - probably because, otherwise, you don't have a way to easily compile it without Dub itself, I guess :P so I'll need to either write my custom color outputting code within Dub's source or just import that library.
>
> Of course making it cross-platform is a mandatory thing to me. Windows also needs some specific stuff to output colors, as you can see in the library I linked, so there are definitely some things to do to support all the platforms. I may even take a look at how DMD itself outputs colored output, I guess it will be nice to keeps things consistent.
>
> As for MacOS having a different background... I don't really own a Mac nor I have ever used one before, so I don't even know how tools usually output their colored text on it. At the moment it just sets the foreground color to green/yellow/blue/whatever, without changing the background, if that was your concern. If you meant that yellow-on-white is not readable... well... I guess so. Maybe two different color palettes should be used? IDK, as I said I never used a Mac before so I don't really know how other tools handle this, maybe if some Mac user could help on this, it would be great.
>
> Thanks for the appreciation by the way!

I love it! I have very little experience with terminal colours, but as far as colourizing text on POSIX its fairly easy. You just need to emit the right ANSI escape sequences [0]. This is what the colorize-d library does.. For Windows before Windows 10, things are more messy. You need to use `handle`s, to get the current state and then correctly set the colours. The real hard part here is adjusting the colour scheme based on the terminal background colour.

[0]: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
June 08, 2018
On Friday, 8 June 2018 at 13:35:36 UTC, gdelazzari wrote:
> Hello everyone, I'm a new user of the language (I've been playing around with it for some months) and I'm really liking it.
>
> [...]

I really like this very much! I think this a great improvement for dub and I believe ist is very Important for is to get out tooling to be on par with the tools from orher languages.

I would love to help you on this. Is there anything in particular you need help with?
June 08, 2018
On Friday, 8 June 2018 at 15:34:06 UTC, Uknown wrote:
> I love it! I have very little experience with terminal colours, but as far as colourizing text on POSIX its fairly easy. You just need to emit the right ANSI escape sequences [0]. This is what the colorize-d library does.. For Windows before Windows 10, things are more messy. You need to use `handle`s, to get the current state and then correctly set the colours. The real hard part here is adjusting the colour scheme based on the terminal background colour.
>
> [0]: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors

Sure, I sort of know how that works, I did some stuff some time ago. Also, regarding Windows, the colorize-d library already handles what you described. I think I'll simply take the source of colorize-d and copy-paste the files in the Dub source, as I saw they've done with some parts of Vibe.d in order to avoid having to fetch Dub packages while compiling Dub itself.

> I would love to help you on this. Is there anything in particular you need help with?

Actually, it's not a difficult task. But, being a bit of a perfectionst, I already spotted the possibility of writing a separate module handling all the terminal output, in order to better separate things. At the moment Dub uses the log module from Vibe.d (as I wrote before, which it seems they've just copy-pasted in dub/internal/vibecompat/core/log.d) to print stuff to the terminal, I think replacing it with a module that handles colors and "tags" like in the screenshots I attacched would be the best option. But in order to do something like this cleanly we should first define well how to structure the output and thus the module handling it. Also documenting stuff a bit. Then we'll need to replace all the calls to logInfo, logDiagnostic, logError, etc... in the entire codebase :P

A quicker option is to just leave the log calls there, add the escape sequences in order to color the wanted words (as it's currently done in the proof-of-concept) and then fix the Vibe.d log module to handle colors on Windows with the same "workaround" that colorize-d uses. That's a faster way indeed, but a bit dirty IMHO. Also, to handle different color schemes (for MacOS/white background terminals) it may become a mess.

So, having a module which handles all the terminal output seems the best option to me, if we want to do stuff cleanly. The main problem is to define its requirements, how it should interface with the rest of the code, how to structure it, etc... then writing the code is the simplest part, as always. I can handle this by myself, but if anyone wants to help that would be really appreciated, especially on planning how to structure the changes. Maybe we can discuss about the implementation on IRC or some other platform?
June 08, 2018
On Friday, 8 June 2018 at 13:35:36 UTC, gdelazzari wrote:
> Hello everyone, I'm a new user of the language (I've been playing around with it for some months) and I'm really liking it.
>
> [...]
>
> I started this thread to have a discussion on this before submitting any pull request (which, in the case of this change being apprecciated, I'll happily take the time to make).
>
> Thanks to anyone in advance,
> Giacomo

While this look okay please in the initial PR don't forget to add code to deactivate colors when DUB will be piped.
« First   ‹ Prev
1 2 3