commandline 0.7.9 → 0.7.10

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/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.7.10 11/06/2005
2
+ - Changed opt() to return @option_data
3
+ - OptionData objects now can respond to methods as well as []
4
+
1
5
  == 0.7.9 11/05/2005
2
6
  === Additions
3
7
  - Renamed gem to lowercase commandline
data/TODO ADDED
@@ -0,0 +1,9 @@
1
+ TODO
2
+ - Support CVS style command line
3
+ - Support auto generated synopsis
4
+ - support expected args
5
+ - change :opt_not_found to :default ?
6
+ - POSIX control from Application
7
+ - User para's in man page
8
+ - blocks for modifying descriptions
9
+ REJECTED
@@ -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 :file # or opt "--file"
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 "--in-file"}"
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(name)
82
- if name.kind_of?(Symbol)
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.9
7
- date: 2005-11-05
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: []