thor 0.17.0 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/{CHANGELOG.rdoc → CHANGELOG.md} +30 -36
  2. data/README.md +10 -3
  3. data/lib/thor.rb +205 -180
  4. data/lib/thor/actions.rb +5 -5
  5. data/lib/thor/actions/create_link.rb +3 -0
  6. data/lib/thor/actions/directory.rb +2 -0
  7. data/lib/thor/actions/file_manipulation.rb +1 -1
  8. data/lib/thor/base.rb +84 -95
  9. data/lib/thor/{task.rb → command.rb} +17 -13
  10. data/lib/thor/core_ext/io_binary_read.rb +12 -0
  11. data/lib/thor/error.rb +4 -7
  12. data/lib/thor/group.rb +30 -33
  13. data/lib/thor/invocation.rb +28 -26
  14. data/lib/thor/parser/options.rb +3 -1
  15. data/lib/thor/runner.rb +21 -20
  16. data/lib/thor/shell/basic.rb +5 -1
  17. data/lib/thor/shell/color.rb +4 -0
  18. data/lib/thor/shell/html.rb +4 -0
  19. data/lib/thor/util.rb +214 -210
  20. data/lib/thor/version.rb +1 -1
  21. data/spec/actions/create_file_spec.rb +1 -1
  22. data/spec/actions/create_link_spec.rb +15 -1
  23. data/spec/actions/directory_spec.rb +18 -5
  24. data/spec/actions/empty_directory_spec.rb +1 -1
  25. data/spec/actions/file_manipulation_spec.rb +13 -13
  26. data/spec/actions/inject_into_file_spec.rb +1 -1
  27. data/spec/actions_spec.rb +1 -1
  28. data/spec/base_spec.rb +40 -24
  29. data/spec/command_spec.rb +80 -0
  30. data/spec/core_ext/hash_with_indifferent_access_spec.rb +1 -1
  31. data/spec/core_ext/ordered_hash_spec.rb +1 -1
  32. data/spec/exit_condition_spec.rb +3 -3
  33. data/spec/fixtures/{task.thor → command.thor} +0 -0
  34. data/spec/fixtures/doc/%file_name%.rb.tt +1 -0
  35. data/spec/fixtures/doc/COMMENTER +11 -0
  36. data/spec/fixtures/doc/README +3 -0
  37. data/spec/fixtures/doc/block_helper.rb +3 -0
  38. data/spec/fixtures/doc/config.rb +1 -0
  39. data/spec/fixtures/doc/config.yaml.tt +1 -0
  40. data/spec/fixtures/doc/excluding/%file_name%.rb.tt +1 -0
  41. data/spec/fixtures/group.thor +24 -10
  42. data/spec/fixtures/invoke.thor +3 -3
  43. data/spec/fixtures/script.thor +40 -15
  44. data/spec/fixtures/subcommand.thor +17 -0
  45. data/spec/group_spec.rb +13 -13
  46. data/spec/{spec_helper.rb → helper.rb} +11 -7
  47. data/spec/invocation_spec.rb +16 -16
  48. data/spec/parser/argument_spec.rb +4 -4
  49. data/spec/parser/arguments_spec.rb +1 -1
  50. data/spec/parser/option_spec.rb +1 -1
  51. data/spec/parser/options_spec.rb +6 -1
  52. data/spec/rake_compat_spec.rb +1 -1
  53. data/spec/register_spec.rb +12 -12
  54. data/spec/runner_spec.rb +36 -36
  55. data/spec/shell/basic_spec.rb +9 -10
  56. data/spec/shell/color_spec.rb +16 -2
  57. data/spec/shell/html_spec.rb +1 -1
  58. data/spec/shell_spec.rb +1 -1
  59. data/spec/subcommand_spec.rb +30 -0
  60. data/spec/thor_spec.rb +81 -78
  61. data/spec/util_spec.rb +10 -10
  62. data/thor.gemspec +22 -18
  63. metadata +49 -38
  64. data/.gitignore +0 -44
  65. data/.rspec +0 -3
  66. data/.travis.yml +0 -8
  67. data/Gemfile +0 -19
  68. data/bin/rake2thor +0 -86
  69. data/lib/thor/core_ext/file_binary_read.rb +0 -9
  70. data/spec/task_spec.rb +0 -80
@@ -1,5 +1,5 @@
1
1
  class Thor
2
- class Task < Struct.new(:name, :description, :long_description, :usage, :options)
2
+ class Command < Struct.new(:name, :description, :long_description, :usage, :options)
3
3
  FILE_REGEXP = /^#{Regexp.escape(File.dirname(__FILE__))}/
4
4
 
5
5
  def initialize(name, description, long_description, usage, options=nil)
@@ -15,27 +15,27 @@ class Thor
15
15
  false
16
16
  end
17
17
 
18
- # By default, a task invokes a method in the thor class. You can change this
19
- # implementation to create custom tasks.
18
+ # By default, a command invokes a method in the thor class. You can change this
19
+ # implementation to create custom commands.
20
20
  def run(instance, args=[])
21
21
  arity = nil
22
22
 
23
23
  if private_method?(instance)
24
- instance.class.handle_no_task_error(name)
24
+ instance.class.handle_no_command_error(name)
25
25
  elsif public_method?(instance)
26
26
  arity = instance.method(name).arity
27
27
  instance.__send__(name, *args)
28
28
  elsif local_method?(instance, :method_missing)
29
29
  instance.__send__(:method_missing, name.to_sym, *args)
30
30
  else
31
- instance.class.handle_no_task_error(name)
31
+ instance.class.handle_no_command_error(name)
32
32
  end
33
33
  rescue ArgumentError => e
34
34
  handle_argument_error?(instance, e, caller) ?
35
- instance.class.handle_argument_error(self, e, arity) : (raise e)
35
+ instance.class.handle_argument_error(self, e, args, arity) : (raise e)
36
36
  rescue NoMethodError => e
37
37
  handle_no_method_error?(instance, e, caller) ?
38
- instance.class.handle_no_task_error(name) : (raise e)
38
+ instance.class.handle_no_command_error(name) : (raise e)
39
39
  end
40
40
 
41
41
  # Returns the formatted usage by injecting given required arguments
@@ -107,26 +107,30 @@ class Thor
107
107
  error.message =~ /^undefined method `#{name}' for #{Regexp.escape(instance.to_s)}$/
108
108
  end
109
109
  end
110
+ Task = Command
110
111
 
111
- # A task that is hidden in help messages but still invocable.
112
- class HiddenTask < Task
112
+ # A command that is hidden in help messages but still invocable.
113
+ class HiddenCommand < Command
113
114
  def hidden?
114
115
  true
115
116
  end
116
117
  end
118
+ HiddenTask = HiddenCommand
117
119
 
118
- # A dynamic task that handles method missing scenarios.
119
- class DynamicTask < Task
120
+ # A dynamic command that handles method missing scenarios.
121
+ class DynamicCommand < Command
120
122
  def initialize(name, options=nil)
121
- super(name.to_s, "A dynamically-generated task", name.to_s, name.to_s, options)
123
+ super(name.to_s, "A dynamically-generated command", name.to_s, name.to_s, options)
122
124
  end
123
125
 
124
126
  def run(instance, args=[])
125
127
  if (instance.methods & [name.to_s, name.to_sym]).empty?
126
128
  super
127
129
  else
128
- instance.class.handle_no_task_error(name)
130
+ instance.class.handle_no_command_error(name)
129
131
  end
130
132
  end
131
133
  end
134
+ DynamicTask = DynamicCommand
135
+
132
136
  end
@@ -0,0 +1,12 @@
1
+ class IO #:nodoc:
2
+ class << self
3
+
4
+ def binread(file, *args)
5
+ raise ArgumentError, "wrong number of arguments (#{1 + args.size} for 1..3)" unless args.size < 3
6
+ File.open(file, 'rb') do |f|
7
+ f.read(*args)
8
+ end
9
+ end unless method_defined? :binread
10
+
11
+ end
12
+ end
@@ -5,17 +5,15 @@ class Thor
5
5
  # Errors that are caused by the developer, like declaring a method which
6
6
  # overwrites a thor keyword, it SHOULD NOT raise a Thor::Error. This way, we
7
7
  # ensure that developer errors are shown with full backtrace.
8
- #
9
8
  class Error < StandardError
10
9
  end
11
10
 
12
- # Raised when a task was not found.
13
- #
14
- class UndefinedTaskError < Error
11
+ # Raised when a command was not found.
12
+ class UndefinedCommandError < Error
15
13
  end
14
+ UndefinedTaskError = UndefinedCommandError
16
15
 
17
- # Raised when a task was found, but not invoked properly.
18
- #
16
+ # Raised when a command was found, but not invoked properly.
19
17
  class InvocationError < Error
20
18
  end
21
19
 
@@ -29,7 +27,6 @@ class Thor
29
27
  end
30
28
 
31
29
  # Raised when a user tries to call a private method encoded in templated filename.
32
- #
33
30
  class PrivateMethodEncodedError < Error
34
31
  end
35
32
  end
@@ -1,9 +1,9 @@
1
1
  require 'thor/base'
2
2
 
3
3
  # Thor has a special class called Thor::Group. The main difference to Thor class
4
- # is that it invokes all tasks at once. It also include some methods that allows
4
+ # is that it invokes all commands at once. It also include some methods that allows
5
5
  # invocations to be done at the class method, which are not available to Thor
6
- # tasks.
6
+ # commands.
7
7
  class Thor::Group
8
8
  class << self
9
9
  # The description for this Thor::Group. If none is provided, but a source root
@@ -48,7 +48,7 @@ class Thor::Group
48
48
  end
49
49
 
50
50
  # Invoke the given namespace or class given. It adds an instance
51
- # method that will invoke the klass and task. You can give a block to
51
+ # method that will invoke the klass and command. You can give a block to
52
52
  # configure how it will be invoked.
53
53
  #
54
54
  # The namespace/class given will have its options showed on the help
@@ -64,12 +64,12 @@ class Thor::Group
64
64
 
65
65
  class_eval <<-METHOD, __FILE__, __LINE__
66
66
  def _invoke_#{name.to_s.gsub(/\W/, '_')}
67
- klass, task = self.class.prepare_for_invocation(nil, #{name.inspect})
67
+ klass, command = self.class.prepare_for_invocation(nil, #{name.inspect})
68
68
 
69
69
  if klass
70
70
  say_status :invoke, #{name.inspect}, #{verbose.inspect}
71
71
  block = self.class.invocation_blocks[#{name.inspect}]
72
- _invoke_for_class_method klass, task, &block
72
+ _invoke_for_class_method klass, command, &block
73
73
  else
74
74
  say_status :error, %(#{name.inspect} [not found]), :red
75
75
  end
@@ -100,7 +100,7 @@ class Thor::Group
100
100
  # In some cases you want to customize how a specified hook is going to be
101
101
  # invoked. You can do that by overwriting the class method
102
102
  # prepare_for_invocation. The class method must necessarily return a klass
103
- # and an optional task.
103
+ # and an optional command.
104
104
  #
105
105
  # ==== Custom invocations
106
106
  #
@@ -127,12 +127,12 @@ class Thor::Group
127
127
 
128
128
  value = options[#{name.inspect}]
129
129
  value = #{name.inspect} if TrueClass === value
130
- klass, task = self.class.prepare_for_invocation(#{name.inspect}, value)
130
+ klass, command = self.class.prepare_for_invocation(#{name.inspect}, value)
131
131
 
132
132
  if klass
133
133
  say_status :invoke, value, #{verbose.inspect}
134
134
  block = self.class.invocation_blocks[#{name.inspect}]
135
- _invoke_for_class_method klass, task, &block
135
+ _invoke_for_class_method klass, command, &block
136
136
  else
137
137
  say_status :error, %(\#{value} [not found]), :red
138
138
  end
@@ -149,7 +149,7 @@ class Thor::Group
149
149
  #
150
150
  def remove_invocation(*names)
151
151
  names.each do |name|
152
- remove_task(name)
152
+ remove_command(name)
153
153
  remove_class_option(name)
154
154
  invocations.delete(name)
155
155
  invocation_blocks.delete(name)
@@ -196,30 +196,26 @@ class Thor::Group
196
196
  end
197
197
  end
198
198
 
199
- # Returns tasks ready to be printed.
200
- def printable_tasks(*)
199
+ # Returns commands ready to be printed.
200
+ def printable_commands(*)
201
201
  item = []
202
202
  item << banner
203
203
  item << (desc ? "# #{desc.gsub(/\s+/m,' ')}" : "")
204
204
  [item]
205
205
  end
206
+ alias printable_tasks printable_commands
206
207
 
207
- def handle_argument_error(task, error, arity=nil) #:nodoc:
208
- if arity > 0
209
- msg = "#{basename} #{task.name} takes #{arity} argument"
210
- msg << "s" if arity > 1
211
- msg << ", but it should not."
212
- else
213
- msg = "You should not pass arguments to #{basename} #{task.name}."
214
- end
215
-
208
+ def handle_argument_error(command, error, args, arity) #:nodoc:
209
+ msg = "#{basename} #{command.name} takes #{arity} argument"
210
+ msg << "s" if arity > 1
211
+ msg << ", but it should not."
216
212
  raise error, msg
217
213
  end
218
214
 
219
215
  protected
220
216
 
221
217
  # The method responsible for dispatching given the args.
222
- def dispatch(task, given_args, given_opts, config) #:nodoc:
218
+ def dispatch(command, given_args, given_opts, config) #:nodoc:
223
219
  if Thor::HELP_MAPPINGS.include?(given_args.first)
224
220
  help(config[:shell])
225
221
  return
@@ -230,10 +226,9 @@ class Thor::Group
230
226
 
231
227
  instance = new(args, opts, config)
232
228
  yield instance if block_given?
233
- args = instance.args
234
229
 
235
- if task
236
- instance.invoke_task(all_tasks[task])
230
+ if command
231
+ instance.invoke_command(all_commands[command])
237
232
  else
238
233
  instance.invoke_all
239
234
  end
@@ -242,22 +237,24 @@ class Thor::Group
242
237
  # The banner for this class. You can customize it if you are invoking the
243
238
  # thor class by another ways which is not the Thor::Runner.
244
239
  def banner
245
- "#{basename} #{self_task.formatted_usage(self, false)}"
240
+ "#{basename} #{self_command.formatted_usage(self, false)}"
246
241
  end
247
242
 
248
- # Represents the whole class as a task.
249
- def self_task #:nodoc:
250
- Thor::DynamicTask.new(self.namespace, class_options)
243
+ # Represents the whole class as a command.
244
+ def self_command #:nodoc:
245
+ Thor::DynamicCommand.new(self.namespace, class_options)
251
246
  end
247
+ alias self_task self_command
252
248
 
253
249
  def baseclass #:nodoc:
254
250
  Thor::Group
255
251
  end
256
252
 
257
- def create_task(meth) #:nodoc:
258
- tasks[meth.to_s] = Thor::Task.new(meth, nil, nil, nil, nil)
253
+ def create_command(meth) #:nodoc:
254
+ commands[meth.to_s] = Thor::Command.new(meth, nil, nil, nil, nil)
259
255
  true
260
256
  end
257
+ alias create_task create_command
261
258
  end
262
259
 
263
260
  include Thor::Base
@@ -266,19 +263,19 @@ class Thor::Group
266
263
 
267
264
  # Shortcut to invoke with padding and block handling. Use internally by
268
265
  # invoke and invoke_from_option class methods.
269
- def _invoke_for_class_method(klass, task=nil, *args, &block) #:nodoc:
266
+ def _invoke_for_class_method(klass, command=nil, *args, &block) #:nodoc:
270
267
  with_padding do
271
268
  if block
272
269
  case block.arity
273
270
  when 3
274
- block.call(self, klass, task)
271
+ block.call(self, klass, command)
275
272
  when 2
276
273
  block.call(self, klass)
277
274
  when 1
278
275
  instance_exec(klass, &block)
279
276
  end
280
277
  else
281
- invoke klass, task, *args
278
+ invoke klass, command, *args
282
279
  end
283
280
  end
284
281
  end
@@ -6,12 +6,12 @@ class Thor
6
6
 
7
7
  module ClassMethods
8
8
  # This method is responsible for receiving a name and find the proper
9
- # class and task for it. The key is an optional parameter which is
9
+ # class and command for it. The key is an optional parameter which is
10
10
  # available only in class methods invocations (i.e. in Thor::Group).
11
11
  def prepare_for_invocation(key, name) #:nodoc:
12
12
  case name
13
13
  when Symbol, String
14
- Thor::Util.find_class_and_task_by_namespace(name.to_s, !key)
14
+ Thor::Util.find_class_and_command_by_namespace(name.to_s, !key)
15
15
  else
16
16
  name
17
17
  end
@@ -25,15 +25,15 @@ class Thor
25
25
  super
26
26
  end
27
27
 
28
- # Receives a name and invokes it. The name can be a string (either "task" or
29
- # "namespace:task"), a Thor::Task, a Class or a Thor instance. If the task
30
- # cannot be guessed by name, it can also be supplied as second argument.
28
+ # Receives a name and invokes it. The name can be a string (either "command" or
29
+ # "namespace:command"), a Thor::Command, a Class or a Thor instance. If the
30
+ # command cannot be guessed by name, it can also be supplied as second argument.
31
31
  #
32
32
  # You can also supply the arguments, options and configuration values for
33
- # the task to be invoked, if none is given, the same values used to
33
+ # the command to be invoked, if none is given, the same values used to
34
34
  # initialize the invoker are used to initialize the invoked.
35
35
  #
36
- # When no name is given, it will invoke the default task of the current class.
36
+ # When no name is given, it will invoke the default command of the current class.
37
37
  #
38
38
  # ==== Examples
39
39
  #
@@ -54,16 +54,16 @@ class Thor
54
54
  # end
55
55
  # end
56
56
  #
57
- # You can notice that the method "foo" above invokes two tasks: "bar",
57
+ # You can notice that the method "foo" above invokes two commands: "bar",
58
58
  # which belongs to the same class and "hello" which belongs to the class B.
59
59
  #
60
- # By using an invocation system you ensure that a task is invoked only once.
60
+ # By using an invocation system you ensure that a command is invoked only once.
61
61
  # In the example above, invoking "foo" will invoke "b:hello" just once, even
62
62
  # if it's invoked later by "bar" method.
63
63
  #
64
64
  # When class A invokes class B, all arguments used on A initialization are
65
65
  # supplied to B. This allows lazy parse of options. Let's suppose you have
66
- # some rspec tasks:
66
+ # some rspec commands:
67
67
  #
68
68
  # class Rspec < Thor::Group
69
69
  # class_option :mock_framework, :type => :string, :default => :rr
@@ -100,30 +100,31 @@ class Thor
100
100
  end
101
101
 
102
102
  args.unshift(nil) if Array === args.first || NilClass === args.first
103
- task, args, opts, config = args
103
+ command, args, opts, config = args
104
104
 
105
- klass, task = _retrieve_class_and_task(name, task)
105
+ klass, command = _retrieve_class_and_command(name, command)
106
106
  raise "Expected Thor class, got #{klass}" unless klass <= Thor::Base
107
107
 
108
108
  args, opts, config = _parse_initialization_options(args, opts, config)
109
- klass.send(:dispatch, task, args, opts, config) do |instance|
109
+ klass.send(:dispatch, command, args, opts, config) do |instance|
110
110
  instance.parent_options = options
111
111
  end
112
112
  end
113
113
 
114
- # Invoke the given task if the given args.
115
- def invoke_task(task, *args) #:nodoc:
114
+ # Invoke the given command if the given args.
115
+ def invoke_command(command, *args) #:nodoc:
116
116
  current = @_invocations[self.class]
117
117
 
118
- unless current.include?(task.name)
119
- current << task.name
120
- task.run(self, *args)
118
+ unless current.include?(command.name)
119
+ current << command.name
120
+ command.run(self, *args)
121
121
  end
122
122
  end
123
+ alias invoke_task invoke_command
123
124
 
124
- # Invoke all tasks for the current instance.
125
+ # Invoke all commands for the current instance.
125
126
  def invoke_all #:nodoc:
126
- self.class.all_tasks.map { |_, task| invoke_task(task) }
127
+ self.class.all_commands.map { |_, command| invoke_command(command) }
127
128
  end
128
129
 
129
130
  # Invokes using shell padding.
@@ -138,21 +139,22 @@ class Thor
138
139
  { :invocations => @_invocations }
139
140
  end
140
141
 
141
- # This method simply retrieves the class and task to be invoked.
142
- # If the name is nil or the given name is a task in the current class,
142
+ # This method simply retrieves the class and command to be invoked.
143
+ # If the name is nil or the given name is a command in the current class,
143
144
  # use the given name and return self as class. Otherwise, call
144
145
  # prepare_for_invocation in the current class.
145
- def _retrieve_class_and_task(name, sent_task=nil) #:nodoc:
146
+ def _retrieve_class_and_command(name, sent_command=nil) #:nodoc:
146
147
  case
147
148
  when name.nil?
148
149
  [self.class, nil]
149
- when self.class.all_tasks[name.to_s]
150
+ when self.class.all_commands[name.to_s]
150
151
  [self.class, name.to_s]
151
152
  else
152
- klass, task = self.class.prepare_for_invocation(nil, name)
153
- [klass, task || sent_task]
153
+ klass, command = self.class.prepare_for_invocation(nil, name)
154
+ [klass, command || sent_command]
154
155
  end
155
156
  end
157
+ alias _retrieve_class_and_task _retrieve_class_and_command
156
158
 
157
159
  # Initialize klass using values stored in the @_initializer.
158
160
  def _parse_initialization_options(args, opts, config) #:nodoc:
@@ -46,7 +46,8 @@ class Thor
46
46
  @switches[option.switch_name] = option
47
47
 
48
48
  option.aliases.each do |short|
49
- @shorts[short.to_s] ||= option.switch_name
49
+ name = short.to_s.sub(/^(?!\-)/, '-')
50
+ @shorts[name] ||= option.switch_name
50
51
  end
51
52
  end
52
53
  end
@@ -93,6 +94,7 @@ class Thor
93
94
  option = switch_option(switch)
94
95
  @assigns[option.human_name] = parse_peek(switch, option)
95
96
  elsif @stop_on_unknown
97
+ @parsing_options = false
96
98
  @extra << shifted
97
99
  @extra << shift while peek
98
100
  break
@@ -1,6 +1,6 @@
1
1
  require 'thor'
2
2
  require 'thor/group'
3
- require 'thor/core_ext/file_binary_read'
3
+ require 'thor/core_ext/io_binary_read'
4
4
 
5
5
  require 'fileutils'
6
6
  require 'open-uri'
@@ -16,33 +16,33 @@ class Thor::Runner < Thor #:nodoc:
16
16
  def help(meth = nil)
17
17
  if meth && !self.respond_to?(meth)
18
18
  initialize_thorfiles(meth)
19
- klass, task = Thor::Util.find_class_and_task_by_namespace(meth)
20
- self.class.handle_no_task_error(task, false) if klass.nil?
21
- klass.start(["-h", task].compact, :shell => self.shell)
19
+ klass, command = Thor::Util.find_class_and_command_by_namespace(meth)
20
+ self.class.handle_no_command_error(command, false) if klass.nil?
21
+ klass.start(["-h", command].compact, :shell => self.shell)
22
22
  else
23
23
  super
24
24
  end
25
25
  end
26
26
 
27
- # If a task is not found on Thor::Runner, method missing is invoked and
28
- # Thor::Runner is then responsible for finding the task in all classes.
27
+ # If a command is not found on Thor::Runner, method missing is invoked and
28
+ # Thor::Runner is then responsible for finding the command in all classes.
29
29
  #
30
30
  def method_missing(meth, *args)
31
31
  meth = meth.to_s
32
32
  initialize_thorfiles(meth)
33
- klass, task = Thor::Util.find_class_and_task_by_namespace(meth)
34
- self.class.handle_no_task_error(task, false) if klass.nil?
35
- args.unshift(task) if task
33
+ klass, command = Thor::Util.find_class_and_command_by_namespace(meth)
34
+ self.class.handle_no_command_error(command, false) if klass.nil?
35
+ args.unshift(command) if command
36
36
  klass.start(args, :shell => self.shell)
37
37
  end
38
38
 
39
- desc "install NAME", "Install an optionally named Thor file into your system tasks"
39
+ desc "install NAME", "Install an optionally named Thor file into your system commands"
40
40
  method_options :as => :string, :relative => :boolean, :force => :boolean
41
41
  def install(name)
42
42
  initialize_thorfiles
43
43
 
44
44
  # If a directory name is provided as the argument, look for a 'main.thor'
45
- # task in said directory.
45
+ # command in said directory.
46
46
  begin
47
47
  if File.directory?(File.expand_path(name))
48
48
  base, package = File.join(name, "main.thor"), :directory
@@ -143,14 +143,14 @@ class Thor::Runner < Thor #:nodoc:
143
143
  end
144
144
  end
145
145
 
146
- desc "installed", "List the installed Thor modules and tasks"
146
+ desc "installed", "List the installed Thor modules and commands"
147
147
  method_options :internal => :boolean
148
148
  def installed
149
149
  initialize_thorfiles(nil, true)
150
150
  display_klasses(true, options["internal"])
151
151
  end
152
152
 
153
- desc "list [SEARCH]", "List the available thor tasks (--substring means .*SEARCH)"
153
+ desc "list [SEARCH]", "List the available thor commands (--substring means .*SEARCH)"
154
154
  method_options :substring => :boolean, :group => :string, :all => :boolean, :debug => :boolean
155
155
  def list(search="")
156
156
  initialize_thorfiles
@@ -168,8 +168,8 @@ class Thor::Runner < Thor #:nodoc:
168
168
 
169
169
  private
170
170
 
171
- def self.banner(task, all = false, subcommand = false)
172
- "thor " + task.formatted_usage(self, all, subcommand)
171
+ def self.banner(command, all = false, subcommand = false)
172
+ "thor " + command.formatted_usage(self, all, subcommand)
173
173
  end
174
174
 
175
175
  def thor_root
@@ -276,25 +276,25 @@ class Thor::Runner < Thor #:nodoc:
276
276
  def display_klasses(with_modules=false, show_internal=false, klasses=Thor::Base.subclasses)
277
277
  klasses -= [Thor, Thor::Runner, Thor::Group] unless show_internal
278
278
 
279
- raise Error, "No Thor tasks available" if klasses.empty?
279
+ raise Error, "No Thor commands available" if klasses.empty?
280
280
  show_modules if with_modules && !thor_yaml.empty?
281
281
 
282
282
  list = Hash.new { |h,k| h[k] = [] }
283
283
  groups = klasses.select { |k| k.ancestors.include?(Thor::Group) }
284
284
 
285
285
  # Get classes which inherit from Thor
286
- (klasses - groups).each { |k| list[k.namespace.split(":").first] += k.printable_tasks(false) }
286
+ (klasses - groups).each { |k| list[k.namespace.split(":").first] += k.printable_commands(false) }
287
287
 
288
288
  # Get classes which inherit from Thor::Base
289
- groups.map! { |k| k.printable_tasks(false).first }
289
+ groups.map! { |k| k.printable_commands(false).first }
290
290
  list["root"] = groups
291
291
 
292
292
  # Order namespaces with default coming first
293
293
  list = list.sort{ |a,b| a[0].sub(/^default/, '') <=> b[0].sub(/^default/, '') }
294
- list.each { |n, tasks| display_tasks(n, tasks) unless tasks.empty? }
294
+ list.each { |n, commands| display_commands(n, commands) unless commands.empty? }
295
295
  end
296
296
 
297
- def display_tasks(namespace, list) #:nodoc:
297
+ def display_commands(namespace, list) #:nodoc:
298
298
  list.sort!{ |a,b| a[0] <=> b[0] }
299
299
 
300
300
  say shell.set_color(namespace, :blue, true)
@@ -303,6 +303,7 @@ class Thor::Runner < Thor #:nodoc:
303
303
  print_table(list, :truncate => true)
304
304
  say
305
305
  end
306
+ alias display_tasks display_commands
306
307
 
307
308
  def show_modules #:nodoc:
308
309
  info = []