Notes from Build Awesome Command-Line apps
Lately I was going through book and talks on "Build Awesome Command-Line Applications in Ruby: Control Your Computer, Simplify Your Life" by David Bryant Copeland.
Major stuff /me noted down from it are as below :
The UNIX Way
- grepable (One "record" perline)
- cutable (delimited "fieIds")
- exit codes! (O for success, nonzero for failure)
- messaging (stderr) vs. output (stdout)
Why Ruby?
- High-level abstractions
- Still close to the metal (eg. FileUtils)
- Fast (no heavyweight VM to start up)
- Simple packaging/distribution with RubyGems
Ruby, The Ecosystem
- CLI is part of the culture
- Great open-source gems for command-line
- Great open-source gems for everything else
How you should do it
- Check exit codes - plays well!
- Log the command helpful!
- Capture the output - helpful!
- Check exit codes plays well!
- Log the command helpful!
- Capture the output- helpful!
- Think of "future you"
Few CIL gems I liked :
- Rainbow - Create colored output
- Thor - Create a command-suite app simply and easily, as well as Rails generators
- GLI - Create awesome, polished command suites without a lot of code
- Slop - Create simple command-line apps with a syntax similar to trollop.
- Childprocess - Cross-platform ruby library for managing child processes
- Formatador - produce rich output with a tag-like string syntax, including tables and progressbars
- Highline - handle user input and output via a “Q&A” style API, including type conversions and validation
All in All it's a pretty decent read and will help one getting started and running CLI apps in a wink ;)
Recent blog posts
- watir-webdriver web inspector
- gem list to gemfile
- Packing ruby2.0 on debian.
- Made it into The Guinness Book!
- to_h in ruby 2.0
- Filter elements by pattern jQuery.
- Better HTML password fields for mobile ?
- Grayscale image when user offline
- nth-child CSS pseudo-class Christmas colors
- EventEmitter in nodejs