wallix / awless

A Mighty CLI for AWS
http://awless.io/
Apache License 2.0
4.97k stars 263 forks source link

awless doesn't shortens output in pipes #251

Open ivanwills opened 5 years ago

ivanwills commented 5 years ago

The awless command when outputting to a terminal seems to take the terminal width into account (to a certain extent) but as soon as it's put into a pipe it chooses to shorten lines.

Eg use by it's self

|        ID ▲         |      ZONE       |                            NAME                            |  STATE  |    TYPE    |   PUBLIC IP    |  PRIVATE IP   |  UPTIME   |  KEYPAIR  |                                                                                          
|---------------------|-----------------|------------------------------------------------------------|---------|------------|----------------|---------------|-----------|-----------|
| i-000ced7e34dd28e1f | ap-southeast-2a | xxx-xxx-xxxx-xxxxx-xx-xxxxxxxxx-2                          | running | t2.medium  | 54.252.198.133 | 10.120.80.75  | 6 months  | prod-apps |
| i-001cb8b32648575d3 | ap-southeast-2a | xxxxx-xxx-xxx-xxxxx-10-authordispatch-76b9c77              | running | m4.xlarge  |                | 10.120.82.66  | 12 days   | prod-apps |

Use with a pipe to head

$ awless ls instances | head
|        ID ▲         |      ZONE       |                NAME                 |  STATE  |    TYPE    |   PUBLIC IP    |  PRIVATE IP   |  UPTIME   |  KEYPAIR  |
|---------------------|-----------------|-------------------------------------|---------|------------|----------------|---------------|-----------|-----------|
| i-000ced7e34dd28e1f | ap-southeast-2a | xxx-xxx-xxxx-xxxxx-xx-xxxxxxxxx-2   | running | t2.medium  | 54.252.198.133 | 10.120.80.75  | 6 months  | prod-apps |
| i-001cb8b32648575d3 | ap-southeast-2a | xxxxx-xxx-xxx-xxxxx-10-             | running | m4.xlarge  |                | 10.120.82.66  | 12 days   | prod-apps |
|                     |                 | authordispatch-76b9c77              |         |            |                |               |           |           |

I would expect awless to be piped to for example things like a pager (eg less or more) and keep the screen size correct. The above behavior doens't follow normal industry/comunity standards.