trollop 1.7.1 → 1.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -0
- data/lib/trollop.rb +19 -23
- metadata +44 -37
data/History.txt
CHANGED
data/lib/trollop.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
module Trollop
|
7
7
|
|
8
|
-
VERSION = "1.7.
|
8
|
+
VERSION = "1.7.2"
|
9
9
|
|
10
10
|
## Thrown by Parser in the event of a commandline error. Not needed if
|
11
11
|
## you're using the Trollop::options entry.
|
@@ -85,31 +85,31 @@ class Parser
|
|
85
85
|
## fill in :type
|
86
86
|
opts[:type] =
|
87
87
|
case opts[:type]
|
88
|
-
when :flag, :boolean, :bool
|
89
|
-
when :int, :integer
|
90
|
-
when :string
|
91
|
-
when :double, :float
|
88
|
+
when :flag, :boolean, :bool; :flag
|
89
|
+
when :int, :integer; :int
|
90
|
+
when :string; :string
|
91
|
+
when :double, :float; :float
|
92
92
|
when Class
|
93
93
|
case opts[:type].to_s # sigh... there must be a better way to do this
|
94
|
-
when 'TrueClass', 'FalseClass'
|
95
|
-
when 'String'
|
96
|
-
when 'Integer'
|
97
|
-
when 'Float'
|
94
|
+
when 'TrueClass', 'FalseClass'; :flag
|
95
|
+
when 'String'; :string
|
96
|
+
when 'Integer'; :int
|
97
|
+
when 'Float'; :float
|
98
98
|
else
|
99
99
|
raise ArgumentError, "unsupported argument type '#{opts[:type].class.name}'"
|
100
100
|
end
|
101
|
-
when nil
|
101
|
+
when nil; nil
|
102
102
|
else
|
103
103
|
raise ArgumentError, "unsupported argument type '#{opts[:type]}'" unless TYPES.include?(opts[:type])
|
104
104
|
end
|
105
105
|
|
106
106
|
type_from_default =
|
107
107
|
case opts[:default]
|
108
|
-
when Integer
|
109
|
-
when Numeric
|
110
|
-
when TrueClass, FalseClass
|
111
|
-
when String
|
112
|
-
when nil
|
108
|
+
when Integer; :int
|
109
|
+
when Numeric; :float
|
110
|
+
when TrueClass, FalseClass; :flag
|
111
|
+
when String; :string
|
112
|
+
when nil; nil
|
113
113
|
else
|
114
114
|
raise ArgumentError, "unsupported argument type '#{opts[:default].class.name}'"
|
115
115
|
end
|
@@ -330,14 +330,10 @@ class Parser
|
|
330
330
|
left[name] = "--#{spec[:long]}" +
|
331
331
|
(spec[:short] ? ", -#{spec[:short]}" : "") +
|
332
332
|
case spec[:type]
|
333
|
-
when :flag
|
334
|
-
|
335
|
-
when :
|
336
|
-
|
337
|
-
when :string
|
338
|
-
" <s>"
|
339
|
-
when :float
|
340
|
-
" <f>"
|
333
|
+
when :flag; ""
|
334
|
+
when :int; " <i>"
|
335
|
+
when :string; " <s>"
|
336
|
+
when :float; " <f>"
|
341
337
|
end
|
342
338
|
end
|
343
339
|
|
metadata
CHANGED
@@ -1,33 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.0
|
3
|
-
specification_version: 1
|
4
2
|
name: trollop
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.7.
|
7
|
-
date: 2008-01-07 00:00:00 -08:00
|
8
|
-
summary: Trollop is YAFCLAP --- yet another fine commandline argument processing library for Ruby. Trollop is designed to provide the maximal amount of GNU-style argument processing in the minimum number of lines of code (for you, the programmer).
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: wmorgan-trollop@masanjin.net
|
12
|
-
homepage: http://trollop.rubyforge.org
|
13
|
-
rubyforge_project: trollop
|
14
|
-
description: "== DESCRIPTION Trollop is YAFCLAP --- yet another fine commandline argument processor for Ruby. Trollop is designed to provide the maximal amount of GNU-style argument processing in the minimum number of lines of code (for you, the programmer). - Simple usage. - Sensible defaults. No tweaking necessary, much tweaking possible. - Support for long options, short options, short option bundling, and automatic type validation and conversion. - Automatic help message generation, wrapped to current screen width. - Lots of unit tests. Synopsis ###### simple ###### require 'trollop' opts = Trollop::options do opt :monkey, \"Use monkey mode\" opt :goat, \"Use goat mode\", :default => true opt :num_limbs, \"Set number of limbs\", :default => 4 end p opts ###### medium ###### require 'trollop' opts = Trollop::options do version \"test 1.2.3 (c) 2007 William Morgan\" banner <<-EOS Test is an awesome program that does something very, very important. Usage: test [options] <filenames>+ where [options] are: EOS opt :ignore, \"Ignore incorrect values\" opt :file, \"Extra data filename to read in, with a very long option description like this one\", :type => String opt :volume, \"Volume level\", :default => 3.0 opt :iters, \"Number of iterations\", :default => 5 end Trollop::die :volume, \"must be non-negative\" if opts[:volume] < 0 Trollop::die :file, \"must exist\" unless File.exist?(opts[:file]) if opts[:file] ###### real-life ######"
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 1.7.2
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- William Morgan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-01-16 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: "== DESCRIPTION Trollop is YAFCLAP --- yet another fine commandline argument processor for Ruby. Trollop is designed to provide the maximal amount of GNU-style argument processing in the minimum number of lines of code (for you, the programmer). - Simple usage. - Sensible defaults. No tweaking necessary, much tweaking possible. - Support for long options, short options, short option bundling, and automatic type validation and conversion. - Automatic help message generation, wrapped to current screen width. - Lots of unit tests. Synopsis ###### simple ###### require 'trollop' opts = Trollop::options do opt :monkey, \"Use monkey mode\" opt :goat, \"Use goat mode\", :default => true opt :num_limbs, \"Set number of limbs\", :default => 4 end p opts ###### medium ###### require 'trollop' opts = Trollop::options do version \"test 1.2.3 (c) 2007 William Morgan\" banner <<-EOS Test is an awesome program that does something very, very important. Usage: test [options] <filenames>+ where [options] are: EOS opt :ignore, \"Ignore incorrect values\" opt :file, \"Extra data filename to read in, with a very long option description like this one\", :type => String opt :volume, \"Volume level\", :default => 3.0 opt :iters, \"Number of iterations\", :default => 5 end Trollop::die :volume, \"must be non-negative\" if opts[:volume] < 0 Trollop::die :file, \"must exist\" unless File.exist?(opts[:file]) if opts[:file] ###### real-life ######"
|
17
|
+
email: wmorgan-trollop@masanjin.net
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- FAQ.txt
|
24
|
+
- History.txt
|
25
|
+
- Manifest.txt
|
26
|
+
- README.txt
|
31
27
|
files:
|
32
28
|
- FAQ.txt
|
33
29
|
- History.txt
|
@@ -36,21 +32,32 @@ files:
|
|
36
32
|
- Rakefile
|
37
33
|
- lib/trollop.rb
|
38
34
|
- test/test_trollop.rb
|
39
|
-
|
40
|
-
|
35
|
+
has_rdoc: true
|
36
|
+
homepage: http://trollop.rubyforge.org
|
37
|
+
post_install_message:
|
41
38
|
rdoc_options:
|
42
39
|
- --main
|
43
40
|
- README.txt
|
44
|
-
|
45
|
-
-
|
46
|
-
|
47
|
-
|
48
|
-
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: "0"
|
48
|
+
version:
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
53
55
|
requirements: []
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
+
rubyforge_project: trollop
|
58
|
+
rubygems_version: 1.0.1
|
59
|
+
signing_key:
|
60
|
+
specification_version: 2
|
61
|
+
summary: Trollop is YAFCLAP --- yet another fine commandline argument processing library for Ruby. Trollop is designed to provide the maximal amount of GNU-style argument processing in the minimum number of lines of code (for you, the programmer).
|
62
|
+
test_files:
|
63
|
+
- test/test_trollop.rb
|