I see where you're going, but I'm still concerned. Invoking Windows' native color support changes the color of the pen at that particular moment, tightly coupling the colorization time with output time. In Facter, this is less of a big deal, since you're effectively choosing to style content based on its type at output time. In Puppet, especially with the work done on the module tool (and moving forward into Telly), we're seeing a distinct need to decouple those processes. For example, if I want to colorize only version numbers in the module tool's output, a tight coupling means that I have to (in the worst case):
* Decompose the output message on version number boundaries * Iterate over those "chunks" of the output * Print each "chunk" with an appropriate color If I decide to start coloring any other part of the output as well (say, module names), the problem gets more expensive. Injecting ANSI escape sequences into the string as a form of markup (inelegant as it is) gives us flexibility -- we could, in that same example, run a quick s///g and have colorized the string appropriately. While we could easily write our own handler to intercept those escapes on Windows and change the pen color *at output time*, that's exactly what libraries like ansicon and win32console are doing for us. On Wed, Apr 4, 2012 at 12:28 PM, Ken Barber <[email protected]> wrote: > So I guess my (somewhat belaboured) point is that since I abstract > color prints to provide color scheme support - the implementation is > hidden anyway. If the implementation is hidden, then one can use my > implementation which works without any 3rd party gem support since it > just taps that API directly. Of course it matters little anyway, if we > ship our own Ruby & subsequent required gems - but I'm conscious of > how this all affects open source Windows support of course. > > Do you see what thought process I'm going through here? I guess I'm > thinking 2 moves ahead. > > On Wed, Apr 4, 2012 at 8:22 PM, Daniel Pittman <[email protected]> > wrote: > > ansicon is a process that runs between the console and the cmd.exe > > process, translating ANSI escapes into colour. That is pretty heavy, > > indeed. > > > > I agree with Josh: we should just use win32console until it stops > > being awesome, and ideally wrap it in a feature so we can have it fail > > cleanly when not present. > > > > On Wed, Apr 4, 2012 at 10:37, Josh Cooper <[email protected]> wrote: > >> Hey Ken, > >> > >> So yes, win32console[1] is officially deprecated, but the alternative is > >> ansicon[2], but it is fairly invasive and may affect all cmd processes, > may > >> require reboots to install, etc. With that said, win32console seems to > work > >> really well, and was trivial to add support to puppet[3]. So I'm > thinking we > >> should go the win32console route... > >> > >> Josh > >> > >> [1] https://github.com/luislavena/win32console > >> [2] http://adoxa.110mb.com/ansicon/index.html > >> [3] > >> > https://github.com/joshcooper/puppet/commit/d4aa2ba415872cf1e37900322f2deb763a186598 > >> > >> On Wed, Apr 4, 2012 at 9:59 AM, Ken Barber <[email protected]> wrote: > >>> > >>> I know win32console was offering similar functionality for ANSI escape > >>> codes for Windows - but I think last time we looked win32console was > >>> out of maintenance. Have you found something else since then Josh? > >>> > >>> On Wed, Apr 4, 2012 at 5:46 PM, Pieter van de Bruggen > >>> <[email protected]> wrote: > >>> > From what I heard yesterday from Josh (and I reserve the right to > have > >>> > mis-understood), Windows gained support for ANSI escapes, meaning we > no > >>> > longer need to special case the `color` setting for Windows. The > module > >>> > that handles colors in core probably doesn't look that different from > >>> > the > >>> > module that handles colors in Facter -- we should try to consolidate > the > >>> > code. > >>> > > >>> > As for the colors themselves, I'm working on trying to build up a > design > >>> > vocabulary around them that we can use across our products; I'll let > you > >>> > know when we have something more concrete. > >>> > > >>> > > >>> > On Wed, Apr 4, 2012 at 9:35 AM, Daniel Pittman < > [email protected]> > >>> > wrote: > >>> >> > >>> >> On Wed, Apr 4, 2012 at 08:04, Ken Barber <[email protected]> > wrote: > >>> >> > >>> >> > So I managed to get console colors working for Facter that works > in > >>> >> > both Windows & Unix (using ANSI escapes): > >>> >> > >>> >> Awesome. So, in the geordi work the "new console log" output system > >>> >> was defined, which also supports colour. It only does Unix, though, > >>> >> and just gave up on Windows. > >>> >> > >>> >> It would be good to look at integrating the two, at least to the > level > >>> >> of having a copy of the common code between them. > >>> >> > >>> >> That is, otherwise, pretty damn awesome - it will make Win32 much > >>> >> nicer to work with. :) > >>> >> > >>> >> -- > >>> >> Daniel Pittman > >>> >> ⎋ Puppet Labs Developer – http://puppetlabs.com > >>> >> ♲ Made with 100 percent post-consumer electrons > >>> >> > >>> >> -- > >>> >> You received this message because you are subscribed to the Google > >>> >> Groups > >>> >> "Puppet Developers" group. > >>> >> To post to this group, send email to [email protected]. > >>> >> To unsubscribe from this group, send email to > >>> >> [email protected]. > >>> >> For more options, visit this group at > >>> >> http://groups.google.com/group/puppet-dev?hl=en. > >>> >> > >>> > > >>> > -- > >>> > You received this message because you are subscribed to the Google > >>> > Groups > >>> > "Puppet Developers" group. > >>> > To post to this group, send email to [email protected]. > >>> > To unsubscribe from this group, send email to > >>> > [email protected]. > >>> > For more options, visit this group at > >>> > http://groups.google.com/group/puppet-dev?hl=en. > >>> > >>> -- > >>> You received this message because you are subscribed to the Google > Groups > >>> "Puppet Developers" group. > >>> To post to this group, send email to [email protected]. > >>> To unsubscribe from this group, send email to > >>> [email protected]. > >>> For more options, visit this group at > >>> http://groups.google.com/group/puppet-dev?hl=en. > >>> > >> > >> > >> > >> -- > >> Josh Cooper > >> Developer, Puppet Labs > >> > >> -- > >> You received this message because you are subscribed to the Google > Groups > >> "Puppet Developers" group. > >> To post to this group, send email to [email protected]. > >> To unsubscribe from this group, send email to > >> [email protected]. > >> For more options, visit this group at > >> http://groups.google.com/group/puppet-dev?hl=en. > > > > > > > > -- > > Daniel Pittman > > ⎋ Puppet Labs Developer – http://puppetlabs.com > > ♲ Made with 100 percent post-consumer electrons > > > > -- > > You received this message because you are subscribed to the Google > Groups "Puppet Developers" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > [email protected]. > > For more options, visit this group at > http://groups.google.com/group/puppet-dev?hl=en. > > > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Developers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/puppet-dev?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
