question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(Frosting) Add ANSI console

See original GitHub issue

We need to add an ANSI implementation of IConsole to properly display colors when running dotnet cake.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
devleadcommented, Dec 21, 2018

@clmcgrath yes this could be an assembly or in your build “app”, register the type you want to replace.

   public void Configure(ICakeServices services)
    {
        services.RegisterInstance<IConsole>(new TestConsole());
        services.UseContext<Context>();
        services.UseLifetime<Lifetime>();
        services.UseWorkingDirectory("..");
    }

A simple console “proxy” example could look like this

    public class TestConsole : IConsole
    {

        public TestConsole()
        {
        }

        public ConsoleColor ForegroundColor
        { 
            get => Console.ForegroundColor;
            set => Console.ForegroundColor = value;
        }

        public ConsoleColor BackgroundColor
        { 
            get => Console.BackgroundColor;
            set => Console.BackgroundColor = value;
        }

        public void Write(string format, params object[] arg)
            => Console.Write(format, arg);

        public void WriteError(string format, params object[] arg)
            => Console.Error.Write(format, arg);

        public void WriteErrorLine(string format, params object[] arg)
            => Console.Error.WriteLine(format, arg);

        public void WriteLine(string format, params object[] arg)
            => Console.WriteLine(format, arg);

        public void ResetColor()
            => Console.ResetColor();
    }

To be able to use raw ansi codes you would need to use something like

Console.OpenStandardOutput();
var con = new StreamWriter(stdout, Encoding.UTF8);
Console.SetOut(con);

Console.WriteLine("\x1b[36mTEST\x1b[0m");
0reactions
cake-build-botcommented, Feb 7, 2021

🎉 This issue has been resolved in version v1.0.0 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

(Frosting) Add ANSI console · Issue #2892 · cake-build/cake
We need to add an ANSI implementation of IConsole to properly display colors when running dotnet cake.
Read more >
Cake v1.0.0 released
#2892 (Frosting) Add ANSI console. #2893 (Frosting) Align command line parsing with Cake. Documentation. #2962 Document breaking changes in 1.0 ...
Read more >
ANSI.Console 2.5.0
Lightweight and flexible text formatter for creating beautiful console applications.
Read more >
c# - ANSI-Coloring Console Output with .NET
I've created a small plugin (available on NuGet) that allows you to easily wrap your strings in ANSI color codes. Both foreground and...
Read more >
How to Make Canned Frosting Taste Homemade
Dump your canned frosting into a large mixing bowl with a hand mixer or into the bowl of an electric mixer and whip...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found