agent462 / sensu-cli

A Sensu CLI for getting and deleting information from Sensu.
103 stars 42 forks source link

Add functionality to disable coloured output #54

Open madAndroid opened 7 years ago

madAndroid commented 7 years ago

The coloured output is really helpful, but in some situations it makes it difficult to integrate the tool in scripts.. for example we run this during instance startup in AWS:

sensu-cli client history $(facter fqdn) | grep last_status | \
  sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | awk '{print $2}' | egrep '(1|2|3)'

That nasty sed is there to parse the coloured output ASCII codes, otherwise we can't properly grep for last_status codes

Is there a simpler way to do this within the shell output? Alternatively, would you consider adding an option which allows --nocolour ?

agent462 commented 7 years ago

There is a config option currently that you can use to disable, pretty_colors. I can also look at making it a cli flag for people that want it on normally and turn it off on demand.

madAndroid commented 7 years ago

There is a config option currently that you can use to disable, pretty_colors. I can also look at making it a cli flag for people that want it on normally and turn it off on demand.

Thanks, having a cli flag would be really useful :) I'll investigate the config option, although at the moment, we only set the API endpoint there, nothing else