Class: Simp
- Inherits:
-
Object
- Object
- Simp
- Defined in:
- bin/simp
Class Method Summary collapse
-
.parse(args) ⇒ Object
Return a structure describing the options.
Class Method Details
.parse(args) ⇒ Object
Return a structure describing the options.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'bin/simp', line 16 def self.parse(args) # The options specified on the command line will be collected in *options*. # We set default values here. = OpenStruct.new . = [] .url = "" .title = "" opts = OptionParser.new do |opts| opts. = "Usage: example.rb [options]" opts.separator "" opts.separator "Specific options:" # Mandatory argument. opts.on("-l", "--link URL", "The url to save") do |url| .url << url end # Mandatory argument. opts.on("-n", "--name NAME", "The url to save") do |title| .title << title end # List of arguments. opts.on("-t", "--tags foo,bar,baz", Array, "Tags") do || . = end end opts.parse!(args) end |