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

Version Path
newgem-0.13.0 app_generators/newgem/templates/app.rb
newgem-0.13.2 app_generators/newgem/templates/app.rb
newgem-0.13.1 app_generators/newgem/templates/app.rb
newgem-0.13.4 app_generators/newgem/templates/app.rb
newgem-0.13.3 app_generators/newgem/templates/app.rb
newgem-0.14.0 app_generators/newgem/templates/app.rb
newgem-0.14.1 app_generators/newgem/templates/app.rb
newgem-0.15.0 app_generators/newgem/templates/app.rb
newgem-0.14.2 app_generators/newgem/templates/app.rb
newgem-0.13.5 app_generators/newgem/templates/app.rb
newgem-0.18.0 app_generators/newgem/templates/app.rb
newgem-0.17.1 app_generators/newgem/templates/app.rb
newgem-0.16.1 app_generators/newgem/templates/app.rb
newgem-0.17.0 app_generators/newgem/templates/app.rb
newgem-0.16.0 app_generators/newgem/templates/app.rb
newgem-0.19.0 app_generators/newgem/templates/app.rb
newgem-0.19.1 app_generators/newgem/templates/app.rb
newgem-0.20.1 app_generators/newgem/templates/app.rb
newgem-0.21.0 app_generators/newgem/templates/app.rb
newgem-0.20.0 app_generators/newgem/templates/app.rb