Sha256: 9327f0b76e0abeafb5e22a898b09473c8e04a2ea17d116d3601d0b4b380d311c
Contents?: true
Size: 1 KB
Versions: 25
Compression:
Stored size: 1 KB
Contents
#!/usr/bin/env ruby # # Created by <%= author %> on <%= (now = Time.now).year %>-<%= now.month %>-<%= now.day %>. # Copyright (c) <%= now.year %>. All rights reserved. begin require 'rubygems' rescue LoadError # no rubygems to load, so we fail silently end require 'optparse' # NOTE: the option -p/--path= is given as an example, and should probably be replaced in your application. OPTIONS = { :path => '~' } MANDATORY_OPTIONS = %w( path ) parser = OptionParser.new do |opts| opts.banner = <<BANNER This application is wonderful because... Usage: #{File.basename($0)} [options] Options are: BANNER opts.separator "" opts.on("-p", "--path=PATH", String, "The root path for selecting files", "Default: ~") { |OPTIONS[:path]| } opts.on("-h", "--help", "Show this help message.") { puts opts; exit } opts.parse!(ARGV) if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? } puts opts; exit end end path = OPTIONS[:path] # do stuff
Version data entries
25 entries across 25 versions & 1 rubygems