wijet-thor 0.14.7 → 0.14.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -132,6 +132,7 @@ class Thor
132
132
  # :aliases - Aliases for this option.
133
133
  # :type - The type of the argument, can be :string, :hash, :array, :numeric or :boolean.
134
134
  # :banner - String to show on usage notes.
135
+ # :hide - If you want to hide this option from the help.
135
136
  #
136
137
  def method_option(name, options={})
137
138
  scope = if options[:for]
@@ -94,6 +94,8 @@ class Thor
94
94
  end
95
95
 
96
96
  module ClassMethods
97
+ attr_accessor :debugging
98
+
97
99
  def attr_reader(*) #:nodoc:
98
100
  no_tasks { super }
99
101
  end
@@ -210,13 +212,14 @@ class Thor
210
212
  # options<Hash>:: Described below.
211
213
  #
212
214
  # ==== Options
213
- # :desc - Description for the argument.
214
- # :required - If the argument is required or not.
215
- # :default - Default value for this argument.
216
- # :group - The group for this options. Use by class options to output options in different levels.
217
- # :aliases - Aliases for this option.
218
- # :type - The type of the argument, can be :string, :hash, :array, :numeric or :boolean.
219
- # :banner - String to show on usage notes.
215
+ # :desc:: -- Description for the argument.
216
+ # :required:: -- If the argument is required or not.
217
+ # :default:: -- Default value for this argument.
218
+ # :group:: -- The group for this options. Use by class options to output options in different levels.
219
+ # :aliases:: -- Aliases for this option. <b>Note:</b> Thor follows a convention of one-dash-one-letter options. Thus aliases like "-something" wouldn't be parsed; use either "\--something" or "-s" instead.
220
+ # :type:: -- The type of the argument, can be :string, :hash, :array, :numeric or :boolean.
221
+ # :banner:: -- String to show on usage notes.
222
+ # :hide:: -- If you want to hide this option from the help.
220
223
  #
221
224
  def class_option(name, options={})
222
225
  build_option(name, options, class_options)
@@ -382,10 +385,11 @@ class Thor
382
385
  # script.invoke(:task, first_arg, second_arg, third_arg)
383
386
  #
384
387
  def start(given_args=ARGV, config={})
388
+ self.debugging = given_args.delete("--debug")
385
389
  config[:shell] ||= Thor::Base.shell.new
386
390
  dispatch(nil, given_args.dup, nil, config)
387
391
  rescue Thor::Error => e
388
- ENV["THOR_DEBUG"] == "1" ? (raise e) : config[:shell].error(e.message)
392
+ debugging ? (raise e) : config[:shell].error(e.message)
389
393
  exit(1) if exit_on_failure?
390
394
  end
391
395
 
@@ -447,11 +451,13 @@ class Thor
447
451
  padding = options.collect{ |o| o.aliases.size }.max.to_i * 4
448
452
 
449
453
  options.each do |option|
450
- item = [ option.usage(padding) ]
451
- item.push(option.description ? "# #{option.description}" : "")
454
+ unless option.hide
455
+ item = [ option.usage(padding) ]
456
+ item.push(option.description ? "# #{option.description}" : "")
452
457
 
453
- list << item
454
- list << [ "", "# Default: #{option.default}" ] if option.show_default?
458
+ list << item
459
+ list << [ "", "# Default: #{option.default}" ] if option.show_default?
460
+ end
455
461
  end
456
462
 
457
463
  shell.say(group_name ? "#{group_name} options:" : "Options:")
@@ -473,7 +479,7 @@ class Thor
473
479
  def build_option(name, options, scope) #:nodoc:
474
480
  scope[name] = Thor::Option.new(name, options[:desc], options[:required],
475
481
  options[:type], options[:default], options[:banner],
476
- options[:lazy_default], options[:group], options[:aliases])
482
+ options[:lazy_default], options[:group], options[:aliases], options[:hide])
477
483
  end
478
484
 
479
485
  # Receives a hash of options, parse them and add to the scope. This is a
@@ -1,14 +1,15 @@
1
1
  class Thor
2
2
  class Option < Argument #:nodoc:
3
- attr_reader :aliases, :group, :lazy_default
3
+ attr_reader :aliases, :group, :lazy_default, :hide
4
4
 
5
5
  VALID_TYPES = [:boolean, :numeric, :hash, :array, :string]
6
6
 
7
- def initialize(name, description=nil, required=nil, type=nil, default=nil, banner=nil, lazy_default=nil, group=nil, aliases=nil)
7
+ def initialize(name, description=nil, required=nil, type=nil, default=nil, banner=nil, lazy_default=nil, group=nil, aliases=nil, hide=nil)
8
8
  super(name, description, required, type, default, banner)
9
9
  @lazy_default = lazy_default
10
10
  @group = group.to_s.capitalize if group
11
11
  @aliases = [*aliases].compact
12
+ @hide = hide
12
13
  end
13
14
 
14
15
  # This parse quick options given as method_options. It makes several
@@ -1,3 +1,3 @@
1
1
  class Thor
2
- VERSION = "0.14.7".freeze
2
+ VERSION = "0.14.9".freeze
3
3
  end
@@ -227,15 +227,10 @@ describe Thor::Base do
227
227
  end
228
228
 
229
229
  describe "#start" do
230
- it "raises an error instead of rescueing if THOR_DEBUG=1 is given" do
231
- begin
232
- ENV["THOR_DEBUG"] = 1
233
- lambda {
234
- MyScript.start ["what", "--debug"]
235
- }.should raise_error(Thor::UndefinedTaskError, 'Could not find task "what" in "my_script" namespace.')
236
- rescue
237
- ENV["THOR_DEBUG"] = nil
238
- end
230
+ it "raises an error instead of rescueing if --debug is given" do
231
+ lambda {
232
+ MyScript.start ["what", "--debug"]
233
+ }.should raise_error(Thor::UndefinedTaskError, 'Could not find task "what" in "my_script" namespace.')
239
234
  end
240
235
 
241
236
  it "does not steal args" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wijet-thor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.7
4
+ version: 0.14.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-11-21 00:00:00.000000000Z
13
+ date: 2013-03-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
17
- requirement: &2156019540 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,15 @@ dependencies:
22
22
  version: '1.0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *2156019540
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '1.0'
26
31
  - !ruby/object:Gem::Dependency
27
32
  name: fakeweb
28
- requirement: &2156018060 !ruby/object:Gem::Requirement
33
+ requirement: !ruby/object:Gem::Requirement
29
34
  none: false
30
35
  requirements:
31
36
  - - ~>
@@ -33,10 +38,15 @@ dependencies:
33
38
  version: '1.3'
34
39
  type: :development
35
40
  prerelease: false
36
- version_requirements: *2156018060
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '1.3'
37
47
  - !ruby/object:Gem::Dependency
38
48
  name: rdoc
39
- requirement: &2156016680 !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
40
50
  none: false
41
51
  requirements:
42
52
  - - ~>
@@ -44,10 +54,15 @@ dependencies:
44
54
  version: '2.5'
45
55
  type: :development
46
56
  prerelease: false
47
- version_requirements: *2156016680
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: '2.5'
48
63
  - !ruby/object:Gem::Dependency
49
64
  name: rake
50
- requirement: &2156014620 !ruby/object:Gem::Requirement
65
+ requirement: !ruby/object:Gem::Requirement
51
66
  none: false
52
67
  requirements:
53
68
  - - ! '>='
@@ -55,10 +70,15 @@ dependencies:
55
70
  version: '0.8'
56
71
  type: :development
57
72
  prerelease: false
58
- version_requirements: *2156014620
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0.8'
59
79
  - !ruby/object:Gem::Dependency
60
80
  name: rspec
61
- requirement: &2156012020 !ruby/object:Gem::Requirement
81
+ requirement: !ruby/object:Gem::Requirement
62
82
  none: false
63
83
  requirements:
64
84
  - - ~>
@@ -66,10 +86,15 @@ dependencies:
66
86
  version: '2.1'
67
87
  type: :development
68
88
  prerelease: false
69
- version_requirements: *2156012020
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ~>
93
+ - !ruby/object:Gem::Version
94
+ version: '2.1'
70
95
  - !ruby/object:Gem::Dependency
71
96
  name: simplecov
72
- requirement: &2156009560 !ruby/object:Gem::Requirement
97
+ requirement: !ruby/object:Gem::Requirement
73
98
  none: false
74
99
  requirements:
75
100
  - - ~>
@@ -77,7 +102,12 @@ dependencies:
77
102
  version: '0.3'
78
103
  type: :development
79
104
  prerelease: false
80
- version_requirements: *2156009560
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '0.3'
81
111
  description: A scripting framework that replaces rake, sake and rubigen
82
112
  email:
83
113
  - ruby-thor@googlegroups.com
@@ -178,9 +208,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
178
208
  - - ! '>='
179
209
  - !ruby/object:Gem::Version
180
210
  version: '0'
181
- segments:
182
- - 0
183
- hash: 1276832147745609702
184
211
  required_rubygems_version: !ruby/object:Gem::Requirement
185
212
  none: false
186
213
  requirements:
@@ -189,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
216
  version: 1.3.6
190
217
  requirements: []
191
218
  rubyforge_project:
192
- rubygems_version: 1.8.10
219
+ rubygems_version: 1.8.25
193
220
  signing_key:
194
221
  specification_version: 3
195
222
  summary: A scripting framework that replaces rake, sake and rubigen