4 ms·
I has a load of fun when I discovered this too, but eventually realised that a good cli app has focus, sensible use of opts, a succinct -h, reliable exit codes
by teknopaul 5y ago
I has a load of fun when I discovered this too, but eventually realised that a good cli app has focus, sensible use of opts, a succinct -h, reliable exit codes and above all easily parsed output on stdout.
- eropple 5y agoI am all about sensible options, reliable exit codes, and easily parsed output on stdout--but easily parsed output on stdout when it isn't a tty is different from what you show a person when it is a tty.
- nitrogen 5y agoIt's also fairly straightforward to strip escape codes if you need to using sed or similar[0], and there probably already exists a tool that will do just that specifically and more robustly than my example. [0] Here's a basic example I wrote in Ruby: https://github.com/mike-bourgeous/mb-util/blob/5616cc4ce6218b5c541242ac47b0c99a30952a6c/lib/mb/util/text_methods.rb#L21-L24 https://github.com/mike-bourgeous/mb-util/blob/5616cc4ce6218... str.gsub(/\e\[[^A-Za-z~]*[A-Za-z~]/, '')
- rbanffy 5y agoI just select the styling depending on what stdout/stderr are. If output is not going to a terminal, styling strings are empty.