opt-simple 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/README +4 -0
  2. data/lib/opt_simple.rb +11 -9
  3. metadata +2 -2
data/README CHANGED
@@ -70,6 +70,10 @@ require 'opt_simple'
70
70
 
71
71
  puts "Options"
72
72
  puts options
73
+ # access the results using method names or hash syntax
74
+ puts options.pattern
75
+ puts options[:p]
76
+ puts options['glob-pattern']
73
77
 
74
78
  Which prints out an automatic usage statement:
75
79
  Usage: opt_ex.rb [options]
data/lib/opt_simple.rb CHANGED
@@ -115,17 +115,20 @@ class OptSimple
115
115
  # now actually parse the args, and call all the stored up blocks from the options
116
116
  @parameters.each do | parm |
117
117
  intersection = @args & parm.switches
118
+
119
+ # load the defaults for this particular parm no matter what is on the CL
120
+ default_switches = @defaults.keys & parm.names
121
+ if default_switches.length > 1
122
+ raise OptSimple::Error "Clashes in the defaults for #{parm.switches}"
123
+ elsif default_switches.length == 1
124
+ # set the default value before we see what is on the CL
125
+ parm.param_options[default_switches.first] = @defaults[default_switches.first]
126
+ @results.merge! parm.param_options
127
+ end
128
+
118
129
  unless intersection.empty?
119
130
  mandatory_check.delete(parm.switches)
120
- parm.param_options.add_alias(parm.names)
121
131
 
122
- default_switches = @defaults.keys & parm.names
123
- if default_switches.length > 1
124
- raise OptSimple::Error "Clashes in the defaults for #{parm.switches}"
125
- elsif default_switches.length == 1
126
- # set the default value before we see what is on the CL
127
- parm.param_options[default_switches.first] = @defaults[default_switches.first]
128
- end
129
132
 
130
133
  arg_locations = []
131
134
  @args.each_with_index {|arg,i| arg_locations << i if intersection.include?(arg) }
@@ -152,7 +155,6 @@ class OptSimple
152
155
  raise OptSimple::Error.new e.message,self
153
156
  end
154
157
  end
155
-
156
158
  @results.merge! parm.param_options
157
159
  end
158
160
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opt-simple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan Stryker
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2011-03-15 00:00:00 +00:00
12
+ date: 2011-03-16 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies: []
15
15