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.

CLI option to disable ANSI formatting

See original GitHub issue

PR #29 added bold formatting on input words:

screenshot from 2018-06-13 09-21-30

This is cool 😎 but not always desired, for example when piping to a file:

screenshot from 2018-06-13 09-53-26

Flag to disable ANSI could be -p (--plaintext), e.g.

parser.add_argument("-p", "--plaintext",
                    help="output plaintext, disabling ANSI formatting",
                    action="store_true")

ANSI codes could be replaced with a library such as kennethreitz/crayons, which supports disabling colours etc. without too much extra code:

if args.plaintext:
    crayons.disable()

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alxwrdcommented, Jun 13, 2018

I’d suggest timofurrer/colorful. It seems to have better windows support.

the difference between the packages crayons and colorful in a windows environment

Also, I think both crayons and colorful disable ANSI when piping.

$ python -c "import colorful;print(colorful.red('hello'))" > test.txt & cat test.txt
hello
$ python -c "import colorful;print(colorful.red('hello'))" | cat
hello
0reactions
jmsvcommented, Jun 15, 2018

ANSI replaced with colorful in 583ca75ebc1c388d87b86dc62260af401a66e840

Read more comments on GitHub >

github_iconTop Results From Across the Web

NO_COLOR: disabling ANSI color output in various Unix ...
Software Description Date/Version Supported alogview Android logcat Filter 2018‑10‑31 Ammonite Scala Scripting 2017‑07‑03 / 1.0.0 Ansible IT automation system 2021‑04‑26 / 2.11.0
Read more >
3 Methods to Disable ANSI Color Escape Codes for ... - Lindevs
Method 1 - no-ansi option. In order to disable ANSI color escape codes, we can add the --no-ansi option when executing a command....
Read more >
Automatically disable ansi in non-interactive shells · Issue #1417
New feature Generally, big ❤️ to ansi logging. However, in non-interactive terminals, it is a bit of a mess and very difficult to...
Read more >
Windows console with ANSI colors handling - Super User
Create a DWORD key (if necessary) and set its value to 1 to globally enable (or 0 to disable`) ANSI processing by default....
Read more >
How to disable color output of "ng build"? - Stack Overflow
I was unable to find --no-color option to disable ANSI characters into angular-cli output.. Anyway you could remove progress output with ...
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