Sha256: e826f999b479ccfbd86da6eb51314be0e0c432aecd5cdbc47de547bc3d56b013
Contents?: true
Size: 1.3 KB
Versions: 5
Compression:
Stored size: 1.3 KB
Contents
### The following adjusts the load path so that the correct version of ### a self-contained package is found, no matter where the script is ### run from. require 'pathname' $:.unshift((Pathname.new(__FILE__).parent.parent.parent + 'lib').to_s) require 's4t-utils/load-path-auto-adjuster' require 'pp' require 'user-choices' class ArgNotingCommand < UserChoices::Command def add_sources(builder) builder.add_source(UserChoices::CommandLineSource, :usage, "Usage: ruby #{$0} [options] [name]") end def add_choices(builder) # This example shows how you can specify a default value for an # option. builder.add_choice(:choice, :default => 'default') { | command_line | command_line.uses_option("-c", "--choice CHOICE", "CHOICE can be any string.") } # uses_optional_arg allows either zero or one arguments. If an # argument is given, it is directly the value of user_choices[key] # (rather than being stored as a single-element array). builder.add_choice(:name) { | command_line | command_line.uses_optional_arg } end # Perform the command. def execute pp @user_choices end end if $0 == __FILE__ S4tUtils.with_pleasant_exceptions do ArgNotingCommand.new.execute end end
Version data entries
5 entries across 5 versions & 1 rubygems