optix 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +16 -0
- data/examples/thor_style/kitchen_sink.rb +2 -1
- data/lib/optix.rb +8 -2
- data/lib/optix/version.rb +1 -1
- metadata +33 -13
data/README.md
CHANGED
@@ -415,6 +415,22 @@ end
|
|
415
415
|
* Note: Optix does **not** validate or inspect positional parameters.
|
416
416
|
Optix only uses the `params`-String to display a proper synopsis in the help-screen.
|
417
417
|
|
418
|
+
### rename_to
|
419
|
+
|
420
|
+
Override the command name.
|
421
|
+
|
422
|
+
```ruby
|
423
|
+
module Example
|
424
|
+
class Frobnitz < Optix::Cli
|
425
|
+
# Expose this as command 'frobnitz' instead of 'frob'.
|
426
|
+
rename_to "frobnitz"
|
427
|
+
def frob(cmd, opts, argv)
|
428
|
+
...
|
429
|
+
end
|
430
|
+
end
|
431
|
+
end
|
432
|
+
```
|
433
|
+
|
418
434
|
### depends
|
419
435
|
|
420
436
|
Marks two (or more!) options as requiring each other. Only handles
|
@@ -52,7 +52,8 @@ module KitchenSink
|
|
52
52
|
desc "Multiply some numbers"
|
53
53
|
text "Multiplication is ohsom!"
|
54
54
|
params "<int> <int> [int] ..."
|
55
|
-
|
55
|
+
rename_to 'multi'
|
56
|
+
def multi_and_also_demonstrate_renaming(cmd, opts, argv)
|
56
57
|
if argv.length < 2
|
57
58
|
puts "Error: Need at least two parameters!"
|
58
59
|
raise Optix::HelpNeeded
|
data/lib/optix.rb
CHANGED
@@ -302,6 +302,10 @@ class Optix
|
|
302
302
|
@optix_parent = path
|
303
303
|
end
|
304
304
|
|
305
|
+
def rename_to(name)
|
306
|
+
@optix_method_name = name
|
307
|
+
end
|
308
|
+
|
305
309
|
def cli_root(&block)
|
306
310
|
if block
|
307
311
|
add_context(:cli_root, '', &block)
|
@@ -312,12 +316,13 @@ class Optix
|
|
312
316
|
|
313
317
|
def method_added(meth)
|
314
318
|
return if @optix_context.nil?
|
319
|
+
@optix_method_name ||= meth.to_s
|
315
320
|
if @optix_parent == :none
|
316
321
|
cmd_path = nil
|
317
322
|
elsif @optix_parent
|
318
|
-
cmd_path = "#{@optix_parent} #{
|
323
|
+
cmd_path = "#{@optix_parent} #{@optix_method_name}"
|
319
324
|
else
|
320
|
-
cmd_path =
|
325
|
+
cmd_path = @optix_method_name
|
321
326
|
end
|
322
327
|
cmd = Optix::command(cmd_path) {}
|
323
328
|
@optix_context.each do |e|
|
@@ -333,6 +338,7 @@ class Optix
|
|
333
338
|
self.new.send(meth, cmd, opts, argv)
|
334
339
|
end
|
335
340
|
@optix_parent = ''
|
341
|
+
@optix_method_name = nil
|
336
342
|
@optix_context = nil
|
337
343
|
end
|
338
344
|
end
|
data/lib/optix/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chronic
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: rake
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rspec
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: simplecov
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,7 +69,12 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
description: Build flexible, self-documenting command line interfaces with a minimum
|
59
79
|
amount of code.
|
60
80
|
email:
|
@@ -96,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
116
|
version: '0'
|
97
117
|
segments:
|
98
118
|
- 0
|
99
|
-
hash:
|
119
|
+
hash: 3973238625638004697
|
100
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
121
|
none: false
|
102
122
|
requirements:
|
@@ -105,10 +125,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
125
|
version: '0'
|
106
126
|
segments:
|
107
127
|
- 0
|
108
|
-
hash:
|
128
|
+
hash: 3973238625638004697
|
109
129
|
requirements: []
|
110
130
|
rubyforge_project:
|
111
|
-
rubygems_version: 1.8.
|
131
|
+
rubygems_version: 1.8.23
|
112
132
|
signing_key:
|
113
133
|
specification_version: 3
|
114
134
|
summary: Build flexible, self-documenting command line interfaces with a minimum amount
|