aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

Make help text plain when piped to terminal in aws2

Open lousyd opened this issue 6 years ago • 9 comments

I would like for the text output of aws2 to be plain text when it is not sent to tty, i.e. it's going to a pipe or file. If I do this:

[lousyd ~]# /usr/local/bin/aws2 help | grep -- '--query'
       --query (string)

But if I do this:

[lousyd ~]# /usr/local/bin/aws2 help | grep -- '^\s\+--query'

...nothing. That's because:

[lousyd ~]# /usr/local/bin/aws2 help | grep -- '--query' | cat -A
       ^[[1m--query ^[[22m(string)$

There's a bunch of other junk in there meant to make the output look pretty in the terminal. But that junk just gets in the way of standard text processing.

Please either make help output plain text when output is not to a tty, or just output plain text all of the time.

lousyd avatar Nov 14 '19 16:11 lousyd

👍

tchiaspko avatar Dec 17 '19 18:12 tchiaspko

Greetings! It looks like this issue hasn’t been active in longer than one year. We encourage you to check if this is still an issue in the latest release. Because it has been longer than one year since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment to prevent automatic closure, or if the issue is already closed, please feel free to reopen it.

github-actions[bot] avatar Dec 16 '20 19:12 github-actions[bot]

This is still an issue. For example:

[lousyd ~]# aws help topics | cat -A
AWS(CLI)                                                              AWS(CLI)$
$
$
$
^[[1mNAME^[[0m$
       AWS CLI Topic Guide -$
$
^[[1mDESCRIPTION^[[0m$
       This  is  the  AWS  CLI Topic Guide. It gives access to a set of topics$
       that provide a deeper understanding of the CLI. To access the  list  of$
       topics from the command line, run ^[[1maws help topics^[[22m. To access a specific$
       topic from the command line, run ^[[1maws help [topicname]^[[22m, where  ^[[1mtopicname^[[0m$
       is the name of the topic as it appears in the output from ^[[1maws help top-^[[0m$
       ^[[1mics^[[22m.$
$
^[[1mAVAILABLE TOPICS^[[0m$
   ^[[1mGeneral^[[0m$
       +^Ho config-vars: Configuration Variables for the AWS CLI$
$
       +^Ho return-codes: Describes the various return codes of the AWS CLI$
$
   ^[[1mS3^[[0m$
       +^Ho s3-config: Advanced configuration for AWS S3 Commands$
$
       +^Ho s3-faq: Frequented Asked Questions for Amazon S3 in the AWS CLI$
$
   ^[[1mddb^[[0m$
       +^Ho ddb-expressions: Details on the expression syntax for  the  ddb  com-$
         mands$
$
$
$
GUIDE                                TOPIC                            AWS(CLI)$

The dollar signs, carets, "+^Ho", and all of the left brackets but one are just rubbish meant to prettify the output when it goes to a terminal. They aren't part of the content of the help page. I am running version "aws-cli/2.1.12 Python/3.7.3".

lousyd avatar Dec 17 '20 18:12 lousyd

Greetings! It looks like this issue hasn’t been active in longer than one year. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.

github-actions[bot] avatar Feb 09 '22 00:02 github-actions[bot]

This is still an issue. For example:

[lousyd ~]# /usr/local/bin/aws --version
aws-cli/2.4.18 Python/3.8.8 Linux/5.16.8-200.fc35.x86_64 exe/x86_64.fedora.35 prompt/off

[lousyd ~]# aws help topics | cat -A
AWS(CLI)                                                              AWS(CLI)$
$
$
$
^[[1mNAME^[[0m$
       AWS CLI Topic Guide -$
$
^[[1mDESCRIPTION^[[0m$
       This  is  the  AWS  CLI Topic Guide. It gives access to a set of topics$
       that provide a deeper understanding of the CLI. To access the  list  of$
       topics from the command line, run ^[[1maws help topics^[[22m. To access a specific$
       topic from the command line, run ^[[1maws help [topicname]^[[22m, where  ^[[1mtopicname^[[0m$
       is the name of the topic as it appears in the output from ^[[1maws help top-^[[0m$
       ^[[1mics^[[22m.$
$
^[[1mAVAILABLE TOPICS^[[0m$
   ^[[1mGeneral^[[0m$
       +^Ho config-vars: Configuration Variables for the AWS CLI$
$
       +^Ho return-codes: Describes the various return codes of the AWS CLI$
$
   ^[[1mS3^[[0m$
       +^Ho s3-config: Advanced configuration for AWS S3 Commands$
$
       +^Ho s3-faq: Frequented Asked Questions for Amazon S3 in the AWS CLI$
$
   ^[[1mddb^[[0m$
       +^Ho ddb-expressions: Details on the expression syntax for  the  ddb  com-$
         mands$
$
$
$
GUIDE                                TOPIC                            AWS(CLI)$

The dollar signs, carets, "+^Ho", and all of the left brackets but one are just rubbish meant to prettify the output when it goes to a terminal. They aren't part of the content of the help page.

lousyd avatar Feb 16 '22 18:02 lousyd

Still hoping this gets fixed. It causes me problems every once in a while.

lousyd avatar May 14 '23 21:05 lousyd

Still hoping this gets fixed. It causes me problems every once in a while.

Hi @lousyd this doesn't seems to be bug, these are color codes in shell/bash and they are highlighting the required headings, please refer the screenshot. image

rkriplani76 avatar Jul 07 '23 13:07 rkriplani76

It appears that in your screenshot, you're invoking help and looking at the help pages. Is that correct? The problem I see is not when looking at the help page output, but when I pipe the help page output to another program, like grep. See, for example, my original post.

lousyd avatar Jul 24 '23 15:07 lousyd

I have this issue also and it's driving me nuts. By default, I see colored escape codes. So there are proper escape codes for coloring, but I also see the literal escape codes. Screenshot from 2024-02-26 14-22-27

If I pipe to cat, the color disappears, but the codes are still there. Screenshot from 2024-02-26 14-23-04

mathieu-lemay avatar Feb 26 '24 19:02 mathieu-lemay