Skip to content

suppress ansi output for all terminal commands when ansi terminal not available. #147

Open

Description

@bsutton

We already have some code that suppresses ansi output when running on a none ansi device.

We need to review the terminal library to see if we can do further suppression so that the code 'mostly' works when on non-ansi devices.

With methods like write we could try to track row movements and if the row has moved since the last write then we add a newline before doing the next output.
The problem with this idea is that we would possible need to 'intercept' calls to print so we know when it has changed the row.

things to ponder.

Activity

  1. passsy commented on Jun 1, 2021

    @passsy
    Contributor

    Can't we trust stdin.supportsAnsiEscapes?

  2. bsutton commented on Jun 1, 2021

    @bsutton
    CollaboratorAuthor
  3. passsy commented on Jun 2, 2021

    @passsy
    Contributor

    I don't like the idea of green(String) automatically detecting if ansi is supported and eventually apply the ansi color code. That could cause hard to detect bugs.
    But dcli could offer alternative methods of doing just that. i.e. eventuallyGreen(String).

    Similarly, ask could return the default value if stdin isn't available.

    Another option could be a stdout filter, removing all ansi escape sequences. This could become a great interceptor api allowing filtering of different logging levels beyond --verbose.

  4. bsutton commented on Jun 2, 2021

    @bsutton
    CollaboratorAuthor

    Have a read of #149

    Methods like 'green(String)' are already suppressing colour output if ansi is not supported. If you look at $149 the improvements on whether ansi is supported have actually had what is (in my opinion) an undesirable outcome.

    I'm not certain I'm keen on the idea of a stdout filter, i'm not even certain how we would implement it (may be a guarded zone).

    I do like your idea for the ask function as the ask function is a problem in unit tests and having some mode that auto returns the default seems rather useful.

  5. added a commit that references this issue on Dec 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions