How can I change the text color in the windows command prompt

后端 未结 14 2667
南旧
南旧 2020-12-14 22:32

I have a command line program, which outputs logging to the screen.

I want error lines to show up in red. Is there some special character codes I can output to switc

14条回答
  •  我在风中等你
    2020-12-14 23:17

    You need to access the [Win32 Console API](http://msdn.microsoft.com/en-us/library/ms682073(VS.85%29.aspx). Unfortunately, I don't know how you'd do that from Ruby. In Perl, I'd use the Win32::Console module. The Windows console does not respond to ANSI escape codes.

    According to the article on colorizing Ruby output that artur02 mentioned, you need to install & load the win32console gem.

提交回复
热议问题