setup-console
A library that provides a function to fix ANSI escaping problem in Command Prompt on Windows.
Usage
Simply run setup_console::init()
(or setup_console::try_init()
) in the main function before printing anything.
Panics
This only applies to Windows.
setup_console::init()
doesn't panic, but shows message and terminates program with error code obtained from
GetLastError()
instead.
The situations that would lead program to terminate would be
- when stdout is invalid (e.g.
program 1>nul
) - when program fails to run
GetConsoleMode()
- when program fails to run
SetConsoleMode()
If this is not your desired behavior, you can use setup_console::try_init()
which returns Result
.