Sha256: 673b5b1e71b2a2f681a4e377fa4ea9f154492a955659281a7536a7f50502e435
Contents?: true
Size: 1007 Bytes
Versions: 9
Compression:
Stored size: 1007 Bytes
Contents
#!/usr/bin/env ruby # # Created by MYNAME 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
9 entries across 9 versions & 1 rubygems