We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider an example:
import 'package:chalkdart/chalk.dart'; void main() { print(chalk.blue('Hello World!')); }
When we run it with dart run, it outputs blue text in the terminal.
dart run
However if we redirect the output to a file with dart run > out.txt, the escape-sequences are also get copied:
dart run > out.txt
�[34mHello World!�[39m
I believe it's not a correct default behavior. In the simplest case, we can detect the presence of the terminal this way:
import 'dart:io'; import 'package:chalkdart/chalk.dart'; void main(List<String> arguments) { if (stdout.hasTerminal) { print(chalk.blue('Hello World!')); } else { print('Hello World!'); } }
— but at the chalkdart's side.
The text was updated successfully, but these errors were encountered:
I found a better way to force chalkdart to disable colors:
import 'dart:io'; import 'package:chalkdart/chalk.dart'; void main() { Chalk.ansiColorLevelForNewInstances = stdout.hasTerminal ? 3 : 0; print(chalk.blue('Hello World!')); }
Still I believe it should be the default chakdart behavior to allow for clean piping to files.
Sorry, something went wrong.
No branches or pull requests
Consider an example:
When we run it with
dart run
, it outputs blue text in the terminal.However if we redirect the output to a file with
dart run > out.txt
, the escape-sequences are also get copied:I believe it's not a correct default behavior. In the simplest case, we can detect the presence of the terminal this way:
— but at the chalkdart's side.
The text was updated successfully, but these errors were encountered: