commandline 0.7.9 → 0.7.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/TODO +9 -0
- data/docs/posted-docs.index.html +3 -3
- data/lib/commandline/application.rb +2 -15
- data/lib/commandline/optionparser/optiondata.rb +16 -1
- metadata +4 -2
data/CHANGELOG
CHANGED
data/TODO
ADDED
data/docs/posted-docs.index.html
CHANGED
@@ -490,12 +490,12 @@ on the command line. This common case can be done simply with the notation:
|
|
490
490
|
And we retrieve the value with:
|
491
491
|
|
492
492
|
<pre>
|
493
|
-
opt
|
493
|
+
opt.file # or opt["--file"]
|
494
494
|
</pre>
|
495
495
|
|
496
496
|
or, more fully
|
497
497
|
<pre>
|
498
|
-
@option_data["--file"]
|
498
|
+
@option_data.file # or @option_data["--file"]
|
499
499
|
</pre>
|
500
500
|
|
501
501
|
Let's fill this app out a little more completely and look at it in more detail.
|
@@ -521,7 +521,7 @@ Let's fill this app out a little more completely and look at it in more detail.
|
|
521
521
|
|
522
522
|
def main
|
523
523
|
puts "args: #{args}
|
524
|
-
puts "--in-file: #{opt
|
524
|
+
puts "--in-file: #{opt["--in-file"]}"
|
525
525
|
end
|
526
526
|
end#class App
|
527
527
|
</pre>
|
@@ -78,21 +78,8 @@ class Application
|
|
78
78
|
end
|
79
79
|
|
80
80
|
# Alternative for @option_data["<--opt>"], but with symbols
|
81
|
-
def opt
|
82
|
-
|
83
|
-
o1 = "--#{name}"
|
84
|
-
o2 = "-#{name}"
|
85
|
-
if @option_data.has_option?(o1)
|
86
|
-
@option_data[o1]
|
87
|
-
elsif @option_data.has_option?(o2)
|
88
|
-
@option_data[o2]
|
89
|
-
else
|
90
|
-
raise UnknownOptionError, "Unknown options '#{o1}' and '#{o2}'."
|
91
|
-
end
|
92
|
-
else
|
93
|
-
raise UnknownOptionError, "Unknown option '#{name}'." unless @option_data.has_option?(name)
|
94
|
-
@option_data[name]
|
95
|
-
end
|
81
|
+
def opt
|
82
|
+
@option_data
|
96
83
|
end
|
97
84
|
|
98
85
|
#
|
@@ -69,7 +69,22 @@ class OptionData
|
|
69
69
|
def to_h
|
70
70
|
Marshal.load(Marshal.dump(@opts))
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
|
+
# As a convenience, options may be accessed by their name
|
74
|
+
# without the dashes. Of course, this won't work for options
|
75
|
+
# with names like '--with-shared'. For these names, you must
|
76
|
+
# still use option_data['--with-shared']
|
77
|
+
def method_missing(sym)
|
78
|
+
k1 = "--#{sym}"
|
79
|
+
k2 = "-#{sym}"
|
80
|
+
if @opts.has_key?(k1)
|
81
|
+
@opts[k1]
|
82
|
+
elsif @opts.has_key?(k2)
|
83
|
+
@opts[k2]
|
84
|
+
else
|
85
|
+
raise UnknownOptionError, "Unknown option (--|-)#{sym}."
|
86
|
+
end
|
87
|
+
end
|
73
88
|
end#class OptionData
|
74
89
|
|
75
90
|
end#module CommandLine
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
|
|
3
3
|
specification_version: 1
|
4
4
|
name: commandline
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.7.
|
7
|
-
date: 2005-11-
|
6
|
+
version: 0.7.10
|
7
|
+
date: 2005-11-06
|
8
8
|
summary: Tools to facilitate creation of command line applications and flexible parsing of command line options.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -55,12 +55,14 @@ files:
|
|
55
55
|
- CHANGELOG
|
56
56
|
- README
|
57
57
|
- LICENSE
|
58
|
+
- TODO
|
58
59
|
test_files: []
|
59
60
|
rdoc_options: []
|
60
61
|
extra_rdoc_files:
|
61
62
|
- README
|
62
63
|
- LICENSE
|
63
64
|
- CHANGELOG
|
65
|
+
- TODO
|
64
66
|
executables: []
|
65
67
|
extensions: []
|
66
68
|
requirements: []
|