sensu / sensu-go

Simple. Scalable. Multi-cloud monitoring.
https://sensu.io
MIT License
1.02k stars 176 forks source link

sensuctl tabular output looks terrible on some versions of Windows #2906

Open cwjohnston opened 5 years ago

cwjohnston commented 5 years ago

Expected Behavior

sensuctl tabular output should be easy for human operators to read

Current Behavior

sensuctl tabular output on certain versions/configurations of Windows prints "garbage characters"

Possible Solution

Detect terminal characteristics and adjust tabular output formatting accordingly

Steps to Reproduce (for bugs)

  1. On a Windows 10 system, configure sensuctl for a running backend, use tabular output format
  2. Run sensuctl list operations for any resource type
  3. Observe "garbage characters" in tabular output

Context

Garbage characters -- what I believe are control characters which aren't understood by the terminal -- make the output hard to read, increasing operator burden.

Thus far this seems to be a problem primarily on Windows 10.

In my Windows Server 2016 Data Center VM it looks fine:

2019-05-01 at 12 42 PM

In a Windows 10 VM:

2019-05-01 at 1 12 PM

In a user's Windows 10 Powershell:

image

Same user's cmd terminal, also on Windows 10:

image

Your Environment

amdprophet commented 5 years ago

There was an issue with this fix. Reopening.

amdprophet commented 5 years ago

It seems that Cobra doesn't allow for setting the output channel for normal output and errors independently. As a result, everything is sent to os.Stdout with this change. https://github.com/spf13/cobra/blob/5755ecf10233c1acfd87d417bc6605a30702c0a8/command.go#L260-L278

jamesdphillips commented 5 years ago

Requires https://github.com/spf13/cobra/pull/822

amdprophet commented 5 years ago

We may want to add a test to ensure messages go to stdout/stderr correctly after fixing this so that we can avoid having to discover issues in QA.

amdprophet commented 5 years ago

There are still some bugs in Cobra preventing us from fixing this at the moment.

amdprophet commented 5 years ago

Waiting on https://github.com/spf13/cobra/pull/894 to get merged.

portertech commented 5 years ago

Still waiting on the cobra pr.

calebhailey commented 4 years ago

The Cobra PR got approved last week! It's still not merged yet, but here's hoping it happens soon!

calebhailey commented 4 years ago

I also wonder if https://github.com/sensu/sensu-go/issues/3782 would help here

cwjohnston commented 3 years ago

upstream issue fixed and shipped in cobra 1.1.0

calebhailey commented 3 years ago

@fguimond @amdprophet did any of the recent work we've done on sensuctl/cobra 🐍 address this?

fguimond commented 3 years ago

@calebhailey - the issue is still there using the regular Windows command line (dos or PowerShell), however it does work with the new Windows Terminal https://www.microsoft.com/en-ca/p/windows-terminal/9n0dx20hk701?rtc=1&activetab=pivot:overviewtab.

amdprophet commented 3 years ago

We should be able to fix this now by upgrading the version of Cobra we depend on.

calebhailey commented 3 years ago

Ok, great. Thanks for confirming. 👍