Skip to content
New issue

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

[Bug]: Do not output terminal control codes when output is not a terminal #1709

Open
larsks opened this issue Feb 11, 2024 · 3 comments
Open
Assignees
Labels
bug needs triage Waiting for discussion / prioritization by team

Comments

@larsks
Copy link

larsks commented Feb 11, 2024

Steps to Reproduce

Try running some like:

step ca --help | less

Your Environment

  • OS - Fedora 38
  • step-ca Version - 0.25.2

Expected Behavior

I expected to see the help output from step commands displayed in a readable fashion on my screen.

Actual Behavior

This mess:

ESC[0;1;99mNAMEESC[0m
      ESC[0;1;99mstep caESC[0m -- initialize and manage a certificate authority

ESC[0;1;99mUSAGEESC[0m
      ESC[0;1;99mstep caESC[0m ESC[0;4;39mcommandESC[0m ESC[0;4;39m[options]ESC[0m ESC[0;4;39m[arguments]ESC[0m

ESC[0;1;99mDESCRIPTIONESC[0m
      ESC[0;1;99mstep caESC[0m command group provides facilities to initialize a certificate
      authority, retrieve the root of trust, sign and renew certificates, and
      create and manage provisioners.

ESC[0;1;99mOPTIONSESC[0m
      ESC[0;1;99m--helpESC[0m, ESC[0;1;99m-hESC[0m
          show help

ESC[0;1;99mEXAMPLESESC[0m
      Create the configuration for a new certificate authority:

Additional Context

This is common behavior for most programs that are able to generated formatted output on the terminal; they suppress colors/other formatting when the output isn't a tty. Compare, e.g.:

step --help | less

With:

git checkout --help | less

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@larsks larsks added bug needs triage Waiting for discussion / prioritization by team labels Feb 11, 2024
@tashian
Copy link
Contributor

tashian commented Feb 13, 2024

From https://clig.dev/#output :

Screenshot 2024-02-13 at 10 19 44 AM

@hslatman
Copy link
Member

Related issues:

@dopey
Copy link
Contributor

dopey commented Feb 13, 2024

Hey @larsks 👋. Thanks for opening the issue!

I believe this is actually a duplicate of an issue we have on the smallstep/cli repo (as @hslatman referenced above), but it probably makes sense to have an issue in this repo as well.

We definitely agree that supporting --no-color would be a useful feature. We've actually run into this issue a few times ourselves. Unfortunately, after some discussion this morning we came to the realization that this is probably not a "quick fix". We are a small team and we are heavily focused on product roadmap at the moment so we cannot make any guarantees with regards to prioritization. That said, we'd be happy to accept contribution from the community - if anyone is interested in working on this, please let us know as we'd love to help brainstorm and guide the implementation.

Cheers 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs triage Waiting for discussion / prioritization by team
Projects
None yet
Development

No branches or pull requests

4 participants