optitron 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.rdoc +7 -8
- data/lib/optitron/class_dsl.rb +6 -3
- data/lib/optitron/version.rb +1 -1
- data/spec/cli_spec.rb +6 -2
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -115,7 +115,6 @@ Now, try running it.
|
|
115
115
|
class Runner < Optitron::CLI
|
116
116
|
|
117
117
|
class_opt 'verbose'
|
118
|
-
use_help
|
119
118
|
|
120
119
|
desc "Install stuff"
|
121
120
|
opt 'force'
|
@@ -130,14 +129,14 @@ Running this gives you
|
|
130
129
|
|
131
130
|
crapbook-pro:optitron joshua$ ruby ideal.rb --help
|
132
131
|
Commands
|
133
|
-
|
134
|
-
install [file] <
|
135
|
-
-f/--force
|
136
|
-
|
132
|
+
|
133
|
+
install [file] <required="yourmom"> # Install stuff
|
134
|
+
-f/--force
|
135
|
+
|
137
136
|
Global options
|
138
|
-
|
139
|
-
-v/--verbose
|
140
|
-
-?/--help
|
137
|
+
|
138
|
+
-v/--verbose
|
139
|
+
-?/--help # Print help message
|
141
140
|
|
142
141
|
crapbook-pro:optitron joshua$ ruby ideal.rb install
|
143
142
|
File is required
|
data/lib/optitron/class_dsl.rb
CHANGED
@@ -47,9 +47,12 @@ class Optitron
|
|
47
47
|
when :block
|
48
48
|
lasgn = t.shift
|
49
49
|
lasgn.shift
|
50
|
-
|
51
|
-
arg_list
|
52
|
-
|
50
|
+
name = lasgn.shift
|
51
|
+
sub_part = arg_list.find{|arg| arg.first == name}
|
52
|
+
sub_part.clear
|
53
|
+
sub_part << name
|
54
|
+
sub_part << :optional
|
55
|
+
sub_part << @ruby2ruby.process(lasgn.last)
|
53
56
|
end
|
54
57
|
end
|
55
58
|
end
|
data/lib/optitron/version.rb
CHANGED
data/spec/cli_spec.rb
CHANGED
@@ -22,6 +22,10 @@ class CLIExample < Optitron::CLI
|
|
22
22
|
opt 'another_opt_as_well', :default => 123
|
23
23
|
def use_greedy(one, *two)
|
24
24
|
end
|
25
|
+
|
26
|
+
desc "something with an array"
|
27
|
+
def with_array(ary=[1,2,3])
|
28
|
+
end
|
25
29
|
end
|
26
30
|
|
27
31
|
class AnotherCLIExample < Optitron::CLI
|
@@ -43,7 +47,7 @@ end
|
|
43
47
|
describe "Optitron::Parser defaults" do
|
44
48
|
it "should generate the correct help" do
|
45
49
|
CLIExample.build
|
46
|
-
CLIExample.optitron_parser.help.strip.should == "Commands\n\nuse_greedy [one] [two1 two2 ...] # Use this three\n -A/--another_opt_as_well=[NUMERIC] \nuse_too [one] <
|
50
|
+
CLIExample.optitron_parser.help.strip.should == "Commands\n\nuse_greedy [one] [two1 two2 ...] # Use this three\n -A/--another_opt_as_well=[NUMERIC] \nuse # Use this\n -u/--use_opt \nwith_array <ary=[1, 2, 3]> # something with an array\nuse_too [one] <two=\"three\"> # Use this too\n -a/--another_opt \n\nGlobal options\n\n-v/--verbose \n-?/--help # Print help message"
|
47
51
|
end
|
48
52
|
|
49
53
|
it "should dispatch" do
|
@@ -52,7 +56,7 @@ describe "Optitron::Parser defaults" do
|
|
52
56
|
|
53
57
|
it "should generate the correct help" do
|
54
58
|
AnotherCLIExample.build
|
55
|
-
AnotherCLIExample.optitron_parser.help.strip.should == "Commands\n\nuse_too [one] <
|
59
|
+
AnotherCLIExample.optitron_parser.help.strip.should == "Commands\n\nuse_too [one] <two=\"three\"> # Use this too\n -a/--another_opt \n\nGlobal options\n\n-v/--verbose \n-?/--help # Print help message"
|
56
60
|
end
|
57
61
|
|
58
62
|
it "should dispatch with a custom initer" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optitron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 11
|
10
|
+
version: 0.0.11
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Joshua Hull
|