Writing usable scripts in Ruby
Usable command line tools/scripts There are a lot of command line tools written in ruby, python, bash, c or any other languages. They are usable simply because there is a standard way in dealing with them this way can be summarized in the following points: There has to be a usage example/brief help at the finger tips of the user ( by running with -- help or -h) arguments should have default values which are explained in the help misusage or missing mandatory arguments should fire the help message ruby tools OptionParser is part of the standard library in ruby that takes care of this script packaging. they show long and short examples This is an example of the script: require 'optparse' options = {} OptionParser.new do |opts| opts.banner = "Usage: script_name.rb [options]" opts.on("-v", "--[no-]verbose", "Run verbosely") do |v| options[:verbose] = v end end.parse! p options p ARGV # Actual script co...