How do you specify a required switch (not argument) with Ruby OptionParser?
An approach using optparse that provides friendly output on missing switches: #!/usr/bin/env ruby require ‘optparse’ options = {} optparse = OptionParser.new do |opts| opts.on(‘-f’, ‘–from SENDER’, ‘username of sender’) do |sender| options[:from] = sender end opts.on(‘-t’, ‘–to RECIPIENTS’, ‘comma separated list of recipients’) do |recipients| options[:to] = recipients end options[:number_of_files] = 1 opts.on(‘-n’, ‘–num_files NUMBER’, … Read more