optparshie 1.2.0 → 1.2.1
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.
- data/VERSION +1 -1
- data/example/example1.rb +7 -1
- data/lib/optparshie.rb +5 -1
- data/optparshie.gemspec +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.1
|
data/example/example1.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#-*- coding: utf-8 -*-
|
3
3
|
require("../lib/optparshie");
|
4
4
|
|
5
|
-
argv = "--exp --wa -a 2 --on ADDITION".split(/\s+/);
|
5
|
+
argv = "--exp --wa -a 2 --on --no-foo --bar ADDITION".split(/\s+/);
|
6
6
|
puts("test argv: #{argv}");
|
7
7
|
|
8
8
|
opt = OptionParshie.new();
|
@@ -10,6 +10,8 @@ opt.on("-a","--a-value=VAL");
|
|
10
10
|
opt.on("--exp");
|
11
11
|
opt.on("-w","--waros");
|
12
12
|
opt.on("-o","--on");
|
13
|
+
opt.on("--[no-]foo");
|
14
|
+
opt.on("--[no-]bar");
|
13
15
|
|
14
16
|
# parse returns mash
|
15
17
|
puts("opt.parse => #{opt.parse(argv)}");
|
@@ -30,3 +32,7 @@ puts("opt.waros => #{opt.waros}");
|
|
30
32
|
|
31
33
|
# You should access via short option instead.... :X
|
32
34
|
puts("opt.o => #{opt.o}");
|
35
|
+
|
36
|
+
# -no options
|
37
|
+
puts("opt.foo => #{opt.foo}");
|
38
|
+
puts("opt.bar => #{opt.bar}");
|
data/lib/optparshie.rb
CHANGED
@@ -15,7 +15,11 @@ class OptionParshie < OptionParser
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def hash_key_sanitize(switch)
|
18
|
-
|
18
|
+
switch.gsub!(/^--\[no-\]/,"--");
|
19
|
+
switch.gsub!(/^-+/,"")
|
20
|
+
switch.gsub!(/\W/,"_");
|
21
|
+
|
22
|
+
return switch;
|
19
23
|
end
|
20
24
|
|
21
25
|
def hash_sw_add(sw,val)
|
data/optparshie.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optparshie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -95,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
segments:
|
97
97
|
- 0
|
98
|
-
hash: -
|
98
|
+
hash: -3077249028836579576
|
99
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
100
|
none: false
|
101
101
|
requirements:
|