josevalim-thor 0.10.2 → 0.10.3
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/lib/thor/actions/create_file.rb +2 -1
- data/lib/thor/actions/template.rb +1 -1
- data/lib/thor/actions/templater.rb +4 -2
- data/lib/thor/actions.rb +1 -1
- data/lib/thor/base.rb +13 -6
- data/lib/thor/option.rb +8 -4
- data/lib/thor/task.rb +6 -2
- metadata +2 -2
@@ -21,8 +21,9 @@ class Thor
|
|
21
21
|
# create_file "config/apach.conf", "your apache config"
|
22
22
|
#
|
23
23
|
def create_file(destination, data=nil, log_status=true, &block)
|
24
|
-
action
|
24
|
+
action CreateFile.new(self, destination, block || data.to_s, log_status)
|
25
25
|
end
|
26
|
+
alias :add_file :create_file
|
26
27
|
|
27
28
|
# AddFile is a subset of Template, which instead of rendering a file with
|
28
29
|
# ERB, it gets the content from the user.
|
@@ -65,8 +65,10 @@ class Thor
|
|
65
65
|
# Revokes the action.
|
66
66
|
#
|
67
67
|
def revoke!
|
68
|
-
|
69
|
-
|
68
|
+
if exists?
|
69
|
+
say_status :deleted, :green
|
70
|
+
::FileUtils.rm_rf(destination) unless pretend?
|
71
|
+
end
|
70
72
|
end
|
71
73
|
|
72
74
|
protected
|
data/lib/thor/actions.rb
CHANGED
@@ -132,7 +132,7 @@ class Thor
|
|
132
132
|
#
|
133
133
|
# chmod "script/*", 0755
|
134
134
|
#
|
135
|
-
def chmod(
|
135
|
+
def chmod(path, mode, log_status=true)
|
136
136
|
path = File.expand_path(path, root)
|
137
137
|
say_status_if_log :chmod, relative_to_absolute_root(path), log_status
|
138
138
|
FileUtils.chmod_R(mode, path) unless options[:pretend]
|
data/lib/thor/base.rb
CHANGED
@@ -301,12 +301,14 @@ class Thor
|
|
301
301
|
|
302
302
|
printer = lambda do |group_name, options|
|
303
303
|
unless options.empty?
|
304
|
-
|
304
|
+
list = []
|
305
|
+
|
306
|
+
options.each do |option|
|
305
307
|
next if option.argument?
|
306
|
-
[ option.usage, option.description || '' ]
|
307
|
-
end
|
308
308
|
|
309
|
-
|
309
|
+
list << [ option.usage(false), option.description || "" ]
|
310
|
+
list << [ "", "Default: #{option.default}" ] if option.description && option.default
|
311
|
+
end
|
310
312
|
|
311
313
|
if group_name
|
312
314
|
shell.say "#{group_name} options:"
|
@@ -314,7 +316,7 @@ class Thor
|
|
314
316
|
shell.say "Options:"
|
315
317
|
end
|
316
318
|
|
317
|
-
shell.print_table(
|
319
|
+
shell.print_table(list, :emphasize_last => true, :ident => 2)
|
318
320
|
shell.say ""
|
319
321
|
end
|
320
322
|
end
|
@@ -391,7 +393,12 @@ class Thor
|
|
391
393
|
end
|
392
394
|
|
393
395
|
def from_superclass(method, default=nil)
|
394
|
-
self == baseclass
|
396
|
+
if self == baseclass
|
397
|
+
default
|
398
|
+
else
|
399
|
+
value = superclass.send(method)
|
400
|
+
value.dup if value
|
401
|
+
end
|
395
402
|
end
|
396
403
|
|
397
404
|
# SIGNATURE: Sets the baseclass. This is where the superclass lookup
|
data/lib/thor/option.rb
CHANGED
@@ -121,8 +121,12 @@ class Thor
|
|
121
121
|
(str.length > 1 ? "--" : "-") + str
|
122
122
|
end
|
123
123
|
|
124
|
-
def usage
|
125
|
-
sample =
|
124
|
+
def usage(use_default=true)
|
125
|
+
sample = if use_default
|
126
|
+
formatted_default || formatted_value
|
127
|
+
else
|
128
|
+
formatted_value
|
129
|
+
end
|
126
130
|
|
127
131
|
sample = if sample
|
128
132
|
"#{switch_name}=#{sample}"
|
@@ -156,7 +160,7 @@ class Thor
|
|
156
160
|
when :numeric
|
157
161
|
default.to_s
|
158
162
|
when :string, :default
|
159
|
-
default.empty? ? formatted_value : default.to_s
|
163
|
+
default.to_s.empty? ? formatted_value : default.to_s
|
160
164
|
when :hash
|
161
165
|
if default.empty?
|
162
166
|
formatted_value
|
@@ -204,7 +208,7 @@ class Thor
|
|
204
208
|
true
|
205
209
|
end
|
206
210
|
|
207
|
-
def usage
|
211
|
+
def usage(use_default=true)
|
208
212
|
required? ? formatted_value : "[#{formatted_value}]"
|
209
213
|
end
|
210
214
|
end
|
data/lib/thor/task.rb
CHANGED
@@ -28,8 +28,12 @@ class Thor
|
|
28
28
|
rescue ArgumentError => e
|
29
29
|
backtrace = sans_backtrace(e.backtrace, caller)
|
30
30
|
|
31
|
-
if
|
32
|
-
|
31
|
+
if backtrace.empty? && e.message =~ /wrong number of arguments/
|
32
|
+
if instance.is_a?(Thor::Group)
|
33
|
+
raise e, "'#{name}' was called incorrectly. Are you sure it has arity equals to 0?"
|
34
|
+
else
|
35
|
+
raise InvocationError, "'#{name}' was called incorrectly. Call as '#{formatted_usage(instance.class, true)}'"
|
36
|
+
end
|
33
37
|
else
|
34
38
|
raise e
|
35
39
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: josevalim-thor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yehuda Katz
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-16 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|