josevalim-thor 0.10.5 → 0.10.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/thor/actions.rb +8 -1
- data/lib/thor/group.rb +9 -2
- data/lib/thor.rb +11 -2
- metadata +1 -1
data/lib/thor/actions.rb
CHANGED
@@ -53,8 +53,15 @@ class Thor
|
|
53
53
|
:invoke
|
54
54
|
end
|
55
55
|
|
56
|
-
self.root = config[:root]
|
57
56
|
super
|
57
|
+
|
58
|
+
self.root = config[:root]
|
59
|
+
|
60
|
+
# For last, invoke source root to allow the result to be cached. This is
|
61
|
+
# needed because source root depends on the file location (__FILE__) which
|
62
|
+
# returns the wrong value if invoked after FileUtils#cd.
|
63
|
+
#
|
64
|
+
self.source_root if self.class.respond_to?(:source_root)
|
58
65
|
end
|
59
66
|
|
60
67
|
# Wraps an action object and call it accordingly to the thor class behavior.
|
data/lib/thor/group.rb
CHANGED
@@ -47,10 +47,10 @@ class Thor::Group
|
|
47
47
|
#
|
48
48
|
def help(shell, options={})
|
49
49
|
if options[:short]
|
50
|
-
shell.say
|
50
|
+
shell.say banner
|
51
51
|
else
|
52
52
|
shell.say "Usage:"
|
53
|
-
shell.say " #{
|
53
|
+
shell.say " #{banner}"
|
54
54
|
shell.say
|
55
55
|
class_options_help(shell)
|
56
56
|
shell.say self.desc if self.desc
|
@@ -59,6 +59,13 @@ class Thor::Group
|
|
59
59
|
|
60
60
|
protected
|
61
61
|
|
62
|
+
# The banner for this class. You can customize it if you are invoking the
|
63
|
+
# thor class by another means which is not the Thor::Runner.
|
64
|
+
#
|
65
|
+
def banner #:nodoc:
|
66
|
+
"#{self.namespace} #{self.arguments.map {|o| o.usage }.join(' ')}"
|
67
|
+
end
|
68
|
+
|
62
69
|
def baseclass #:nodoc:
|
63
70
|
Thor::Group
|
64
71
|
end
|
data/lib/thor.rb
CHANGED
@@ -157,13 +157,13 @@ class Thor
|
|
157
157
|
raise UndefinedTaskError, "task '#{meth}' could not be found in namespace '#{self.namespace}'" unless task
|
158
158
|
|
159
159
|
shell.say "Usage:"
|
160
|
-
shell.say " #{task
|
160
|
+
shell.say " #{banner(task, options[:namespace])}"
|
161
161
|
shell.say
|
162
162
|
class_options_help(shell, "Class")
|
163
163
|
shell.say task.description
|
164
164
|
else
|
165
165
|
list = (options[:short] ? tasks : all_tasks).map do |_, task|
|
166
|
-
[ task
|
166
|
+
[ banner(task, options[:namespace]), task.short_description || '' ]
|
167
167
|
end
|
168
168
|
|
169
169
|
if options[:short]
|
@@ -180,6 +180,15 @@ class Thor
|
|
180
180
|
|
181
181
|
protected
|
182
182
|
|
183
|
+
# The banner for this class. You can customize it if you are invoking the
|
184
|
+
# thor class by another means which is not the Thor::Runner. It receives
|
185
|
+
# the task that is going to be invoked and if the namespace should be
|
186
|
+
# displayed.
|
187
|
+
#
|
188
|
+
def banner(task, namespace=true) #:nodoc:
|
189
|
+
task.formatted_usage(self, namespace)
|
190
|
+
end
|
191
|
+
|
183
192
|
def baseclass #:nodoc:
|
184
193
|
Thor
|
185
194
|
end
|