thor 0.18.1 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +13 -7
  3. data/Thorfile +4 -5
  4. data/bin/thor +1 -1
  5. data/lib/thor.rb +78 -67
  6. data/lib/thor/actions.rb +57 -56
  7. data/lib/thor/actions/create_file.rb +33 -35
  8. data/lib/thor/actions/create_link.rb +2 -3
  9. data/lib/thor/actions/directory.rb +37 -38
  10. data/lib/thor/actions/empty_directory.rb +67 -69
  11. data/lib/thor/actions/file_manipulation.rb +17 -15
  12. data/lib/thor/actions/inject_into_file.rb +27 -29
  13. data/lib/thor/base.rb +193 -189
  14. data/lib/thor/command.rb +20 -23
  15. data/lib/thor/core_ext/hash_with_indifferent_access.rb +21 -24
  16. data/lib/thor/core_ext/io_binary_read.rb +2 -4
  17. data/lib/thor/core_ext/ordered_hash.rb +9 -11
  18. data/lib/thor/error.rb +5 -1
  19. data/lib/thor/group.rb +53 -54
  20. data/lib/thor/invocation.rb +44 -38
  21. data/lib/thor/line_editor.rb +17 -0
  22. data/lib/thor/line_editor/basic.rb +35 -0
  23. data/lib/thor/line_editor/readline.rb +88 -0
  24. data/lib/thor/parser.rb +4 -4
  25. data/lib/thor/parser/argument.rb +28 -29
  26. data/lib/thor/parser/arguments.rb +102 -98
  27. data/lib/thor/parser/option.rb +26 -22
  28. data/lib/thor/parser/options.rb +86 -86
  29. data/lib/thor/rake_compat.rb +9 -10
  30. data/lib/thor/runner.rb +141 -141
  31. data/lib/thor/shell.rb +27 -34
  32. data/lib/thor/shell/basic.rb +91 -63
  33. data/lib/thor/shell/color.rb +44 -43
  34. data/lib/thor/shell/html.rb +59 -60
  35. data/lib/thor/util.rb +24 -27
  36. data/lib/thor/version.rb +1 -1
  37. data/spec/actions/create_file_spec.rb +25 -27
  38. data/spec/actions/create_link_spec.rb +19 -18
  39. data/spec/actions/directory_spec.rb +31 -31
  40. data/spec/actions/empty_directory_spec.rb +18 -18
  41. data/spec/actions/file_manipulation_spec.rb +38 -28
  42. data/spec/actions/inject_into_file_spec.rb +13 -13
  43. data/spec/actions_spec.rb +43 -43
  44. data/spec/base_spec.rb +45 -38
  45. data/spec/command_spec.rb +13 -14
  46. data/spec/core_ext/hash_with_indifferent_access_spec.rb +19 -19
  47. data/spec/core_ext/ordered_hash_spec.rb +6 -6
  48. data/spec/exit_condition_spec.rb +4 -4
  49. data/spec/fixtures/invoke.thor +19 -0
  50. data/spec/fixtures/script.thor +1 -1
  51. data/spec/group_spec.rb +30 -24
  52. data/spec/helper.rb +28 -15
  53. data/spec/invocation_spec.rb +39 -19
  54. data/spec/line_editor/basic_spec.rb +28 -0
  55. data/spec/line_editor/readline_spec.rb +69 -0
  56. data/spec/line_editor_spec.rb +43 -0
  57. data/spec/parser/argument_spec.rb +12 -12
  58. data/spec/parser/arguments_spec.rb +11 -11
  59. data/spec/parser/option_spec.rb +33 -25
  60. data/spec/parser/options_spec.rb +66 -52
  61. data/spec/quality_spec.rb +75 -0
  62. data/spec/rake_compat_spec.rb +10 -10
  63. data/spec/register_spec.rb +60 -30
  64. data/spec/runner_spec.rb +67 -62
  65. data/spec/sandbox/application.rb +2 -0
  66. data/spec/sandbox/app{1}/README +3 -0
  67. data/spec/sandbox/bundle/execute.rb +6 -0
  68. data/spec/sandbox/bundle/main.thor +1 -0
  69. data/spec/sandbox/command.thor +10 -0
  70. data/spec/sandbox/doc/%file_name%.rb.tt +1 -0
  71. data/spec/sandbox/doc/COMMENTER +11 -0
  72. data/spec/sandbox/doc/README +3 -0
  73. data/spec/sandbox/doc/block_helper.rb +3 -0
  74. data/spec/sandbox/doc/config.rb +1 -0
  75. data/spec/sandbox/doc/config.yaml.tt +1 -0
  76. data/spec/sandbox/doc/excluding/%file_name%.rb.tt +1 -0
  77. data/spec/sandbox/enum.thor +10 -0
  78. data/spec/sandbox/group.thor +128 -0
  79. data/spec/sandbox/invoke.thor +131 -0
  80. data/spec/sandbox/path with spaces b/data/spec/sandbox/path with → spaces +0 -0
  81. data/spec/sandbox/preserve/script.sh +3 -0
  82. data/spec/sandbox/script.thor +220 -0
  83. data/spec/sandbox/subcommand.thor +17 -0
  84. data/spec/shell/basic_spec.rb +107 -86
  85. data/spec/shell/color_spec.rb +32 -8
  86. data/spec/shell/html_spec.rb +3 -4
  87. data/spec/shell_spec.rb +7 -7
  88. data/spec/subcommand_spec.rb +20 -2
  89. data/spec/thor_spec.rb +111 -97
  90. data/spec/util_spec.rb +30 -30
  91. data/thor.gemspec +14 -14
  92. metadata +69 -25
@@ -2,7 +2,7 @@ class Thor
2
2
  class Command < Struct.new(:name, :description, :long_description, :usage, :options)
3
3
  FILE_REGEXP = /^#{Regexp.escape(File.dirname(__FILE__))}/
4
4
 
5
- def initialize(name, description, long_description, usage, options=nil)
5
+ def initialize(name, description, long_description, usage, options = nil)
6
6
  super(name.to_s, description, long_description, usage, options || {})
7
7
  end
8
8
 
@@ -17,7 +17,7 @@ class Thor
17
17
 
18
18
  # By default, a command invokes a method in the thor class. You can change this
19
19
  # implementation to create custom commands.
20
- def run(instance, args=[])
20
+ def run(instance, args = [])
21
21
  arity = nil
22
22
 
23
23
  if private_method?(instance)
@@ -31,11 +31,9 @@ class Thor
31
31
  instance.class.handle_no_command_error(name)
32
32
  end
33
33
  rescue ArgumentError => e
34
- handle_argument_error?(instance, e, caller) ?
35
- instance.class.handle_argument_error(self, e, args, arity) : (raise e)
34
+ handle_argument_error?(instance, e, caller) ? instance.class.handle_argument_error(self, e, args, arity) : (raise e)
36
35
  rescue NoMethodError => e
37
- handle_no_method_error?(instance, e, caller) ?
38
- instance.class.handle_no_command_error(name) : (raise e)
36
+ handle_no_method_error?(instance, e, caller) ? instance.class.handle_no_command_error(name) : (fail e)
39
37
  end
40
38
 
41
39
  # Returns the formatted usage by injecting given required arguments
@@ -43,7 +41,7 @@ class Thor
43
41
  def formatted_usage(klass, namespace = true, subcommand = false)
44
42
  if namespace
45
43
  namespace = klass.namespace
46
- formatted = "#{namespace.gsub(/^(default)/,'')}:"
44
+ formatted = "#{namespace.gsub(/^(default)/, '')}:"
47
45
  end
48
46
  formatted = "#{klass.namespace.split(':').last} " if subcommand
49
47
 
@@ -51,12 +49,12 @@ class Thor
51
49
 
52
50
  # Add usage with required arguments
53
51
  formatted << if klass && !klass.arguments.empty?
54
- usage.to_s.gsub(/^#{name}/) do |match|
55
- match << " " << klass.arguments.map{ |a| a.usage }.compact.join(' ')
56
- end
57
- else
58
- usage.to_s
59
- end
52
+ usage.to_s.gsub(/^#{name}/) do |match|
53
+ match << " " << klass.arguments.map { |a| a.usage }.compact.join(" ")
54
+ end
55
+ else
56
+ usage.to_s
57
+ end
60
58
 
61
59
  # Add required options
62
60
  formatted << " #{required_options}"
@@ -72,7 +70,7 @@ class Thor
72
70
  end
73
71
 
74
72
  def required_options
75
- @required_options ||= options.map{ |_, o| o.usage if o.required? }.compact.sort.join(" ")
73
+ @required_options ||= options.map { |_, o| o.usage if o.required? }.compact.sort.join(" ")
76
74
  end
77
75
 
78
76
  # Given a target, checks if this class name is a public method.
@@ -90,12 +88,12 @@ class Thor
90
88
  end
91
89
 
92
90
  def sans_backtrace(backtrace, caller) #:nodoc:
93
- saned = backtrace.reject { |frame| frame =~ FILE_REGEXP || (frame =~ /\.java:/ && RUBY_PLATFORM =~ /java/) }
94
- saned -= caller
91
+ saned = backtrace.reject { |frame| frame =~ FILE_REGEXP || (frame =~ /\.java:/ && RUBY_PLATFORM =~ /java/) || (frame =~ /^kernel\// && RUBY_ENGINE =~ /rbx/) }
92
+ saned - caller
95
93
  end
96
94
 
97
95
  def handle_argument_error?(instance, error, caller)
98
- not_debugging?(instance) && error.message =~ /wrong number of arguments/ && begin
96
+ not_debugging?(instance) && (error.message =~ /wrong number of arguments/ || error.message =~ /given \d*, expected \d*/) && begin
99
97
  saned = sans_backtrace(error.backtrace, caller)
100
98
  # Ruby 1.9 always include the called method in the backtrace
101
99
  saned.empty? || (saned.size == 1 && RUBY_VERSION >= "1.9")
@@ -107,7 +105,7 @@ class Thor
107
105
  error.message =~ /^undefined method `#{name}' for #{Regexp.escape(instance.to_s)}$/
108
106
  end
109
107
  end
110
- Task = Command
108
+ Task = Command # rubocop:disable ConstantName
111
109
 
112
110
  # A command that is hidden in help messages but still invocable.
113
111
  class HiddenCommand < Command
@@ -115,15 +113,15 @@ class Thor
115
113
  true
116
114
  end
117
115
  end
118
- HiddenTask = HiddenCommand
116
+ HiddenTask = HiddenCommand # rubocop:disable ConstantName
119
117
 
120
118
  # A dynamic command that handles method missing scenarios.
121
119
  class DynamicCommand < Command
122
- def initialize(name, options=nil)
120
+ def initialize(name, options = nil)
123
121
  super(name.to_s, "A dynamically-generated command", name.to_s, name.to_s, options)
124
122
  end
125
123
 
126
- def run(instance, args=[])
124
+ def run(instance, args = [])
127
125
  if (instance.methods & [name.to_s, name.to_sym]).empty?
128
126
  super
129
127
  else
@@ -131,6 +129,5 @@ class Thor
131
129
  end
132
130
  end
133
131
  end
134
- DynamicTask = DynamicCommand
135
-
132
+ DynamicTask = DynamicCommand # rubocop:disable ConstantName
136
133
  end
@@ -1,6 +1,5 @@
1
1
  class Thor
2
2
  module CoreExt #:nodoc:
3
-
4
3
  # A hash with indifferent access and magic predicates.
5
4
  #
6
5
  # hash = Thor::CoreExt::HashWithIndifferentAccess.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true
@@ -10,8 +9,7 @@ class Thor
10
9
  # hash.foo? #=> true
11
10
  #
12
11
  class HashWithIndifferentAccess < ::Hash #:nodoc:
13
-
14
- def initialize(hash={})
12
+ def initialize(hash = {})
15
13
  super()
16
14
  hash.each do |key, value|
17
15
  self[convert_key(key)] = value
@@ -31,7 +29,7 @@ class Thor
31
29
  end
32
30
 
33
31
  def values_at(*indices)
34
- indices.collect { |key| self[convert_key(key)] }
32
+ indices.map { |key| self[convert_key(key)] }
35
33
  end
36
34
 
37
35
  def merge(other)
@@ -50,31 +48,30 @@ class Thor
50
48
  Hash.new(default).merge!(self)
51
49
  end
52
50
 
53
- protected
51
+ protected
54
52
 
55
- def convert_key(key)
56
- key.is_a?(Symbol) ? key.to_s : key
57
- end
53
+ def convert_key(key)
54
+ key.is_a?(Symbol) ? key.to_s : key
55
+ end
58
56
 
59
- # Magic predicates. For instance:
60
- #
61
- # options.force? # => !!options['force']
62
- # options.shebang # => "/usr/lib/local/ruby"
63
- # options.test_framework?(:rspec) # => options[:test_framework] == :rspec
64
- #
65
- def method_missing(method, *args, &block)
66
- method = method.to_s
67
- if method =~ /^(\w+)\?$/
68
- if args.empty?
69
- !!self[$1]
70
- else
71
- self[$1] == args.first
72
- end
57
+ # Magic predicates. For instance:
58
+ #
59
+ # options.force? # => !!options['force']
60
+ # options.shebang # => "/usr/lib/local/ruby"
61
+ # options.test_framework?(:rspec) # => options[:test_framework] == :rspec
62
+ #
63
+ def method_missing(method, *args, &block)
64
+ method = method.to_s
65
+ if method =~ /^(\w+)\?$/
66
+ if args.empty?
67
+ !!self[$1]
73
68
  else
74
- self[method]
69
+ self[$1] == args.first
75
70
  end
71
+ else
72
+ self[method]
76
73
  end
77
-
74
+ end
78
75
  end
79
76
  end
80
77
  end
@@ -1,12 +1,10 @@
1
1
  class IO #:nodoc:
2
2
  class << self
3
-
4
3
  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|
4
+ fail ArgumentError, "wrong number of arguments (#{1 + args.size} for 1..3)" unless args.size < 3
5
+ File.open(file, "rb") do |f|
7
6
  f.read(*args)
8
7
  end
9
8
  end unless method_defined? :binread
10
-
11
9
  end
12
10
  end
@@ -1,7 +1,6 @@
1
1
  class Thor
2
2
  module CoreExt #:nodoc:
3
-
4
- if RUBY_VERSION >= '1.9'
3
+ if RUBY_VERSION >= "1.9"
5
4
  class OrderedHash < ::Hash
6
5
  end
7
6
  else
@@ -24,12 +23,12 @@ class Thor
24
23
  end
25
24
 
26
25
  def []=(key, value)
27
- if node = @hash[key]
26
+ if node = @hash[key] # rubocop:disable AssignmentInCondition
28
27
  node.value = value
29
28
  else
30
29
  node = Node.new(key, value)
31
30
 
32
- if @first.nil?
31
+ if !defined?(@first) || @first.nil?
33
32
  @first = @last = node
34
33
  else
35
34
  node.prev = @last
@@ -43,7 +42,7 @@ class Thor
43
42
  end
44
43
 
45
44
  def delete(key)
46
- if node = @hash[key]
45
+ if node = @hash[key] # rubocop:disable AssignmentInCondition
47
46
  prev_node = node.prev
48
47
  next_node = node.next
49
48
 
@@ -61,25 +60,25 @@ class Thor
61
60
  end
62
61
 
63
62
  def keys
64
- self.map { |k, v| k }
63
+ map { |k, v| k }
65
64
  end
66
65
 
67
66
  def values
68
- self.map { |k, v| v }
67
+ map { |k, v| v }
69
68
  end
70
69
 
71
70
  def each
72
- return unless @first
71
+ return unless defined?(@first) && @first
73
72
  yield [@first.key, @first.value]
74
73
  node = @first
75
- yield [node.key, node.value] while node = node.next
74
+ yield [node.key, node.value] while node = node.next # rubocop:disable AssignmentInCondition
76
75
  self
77
76
  end
78
77
 
79
78
  def merge(other)
80
79
  hash = self.class.new
81
80
 
82
- self.each do |key, value|
81
+ each do |key, value|
83
82
  hash[key] = value
84
83
  end
85
84
 
@@ -95,6 +94,5 @@ class Thor
95
94
  end
96
95
  end
97
96
  end
98
-
99
97
  end
100
98
  end
@@ -11,7 +11,11 @@ class Thor
11
11
  # Raised when a command was not found.
12
12
  class UndefinedCommandError < Error
13
13
  end
14
- UndefinedTaskError = UndefinedCommandError
14
+ UndefinedTaskError = UndefinedCommandError # rubocop:disable ConstantName
15
+
16
+ class AmbiguousCommandError < Error
17
+ end
18
+ AmbiguousTaskError = AmbiguousCommandError # rubocop:disable ConstantName
15
19
 
16
20
  # Raised when a command was found, but not invoked properly.
17
21
  class InvocationError < Error
@@ -1,10 +1,10 @@
1
- require 'thor/base'
1
+ require "thor/base"
2
2
 
3
3
  # Thor has a special class called Thor::Group. The main difference to Thor class
4
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
6
  # commands.
7
- class Thor::Group
7
+ class Thor::Group # rubocop:disable ClassLength
8
8
  class << self
9
9
  # The description for this Thor::Group. If none is provided, but a source root
10
10
  # exists, tries to find the USAGE one folder above it, otherwise searches
@@ -13,12 +13,11 @@ class Thor::Group
13
13
  # ==== Parameters
14
14
  # description<String>:: The description for this Thor::Group.
15
15
  #
16
- def desc(description=nil)
17
- @desc = case description
18
- when nil
19
- @desc || from_superclass(:desc, nil)
16
+ def desc(description = nil)
17
+ if description
18
+ @desc = description
20
19
  else
21
- description
20
+ @desc ||= from_superclass(:desc, nil)
22
21
  end
23
22
  end
24
23
 
@@ -32,7 +31,7 @@ class Thor::Group
32
31
  shell.say " #{banner}\n"
33
32
  shell.say
34
33
  class_options_help(shell)
35
- shell.say self.desc if self.desc
34
+ shell.say desc if desc
36
35
  end
37
36
 
38
37
  # Stores invocations for this class merging with superclass values.
@@ -54,7 +53,7 @@ class Thor::Group
54
53
  # The namespace/class given will have its options showed on the help
55
54
  # usage. Check invoke_from_option for more information.
56
55
  #
57
- def invoke(*names, &block)
56
+ def invoke(*names, &block) # rubocop:disable MethodLength
58
57
  options = names.last.is_a?(Hash) ? names.pop : {}
59
58
  verbose = options.fetch(:verbose, true)
60
59
 
@@ -63,7 +62,7 @@ class Thor::Group
63
62
  invocation_blocks[name] = block if block_given?
64
63
 
65
64
  class_eval <<-METHOD, __FILE__, __LINE__
66
- def _invoke_#{name.to_s.gsub(/\W/, '_')}
65
+ def _invoke_#{name.to_s.gsub(/\W/, "_")}
67
66
  klass, command = self.class.prepare_for_invocation(nil, #{name.inspect})
68
67
 
69
68
  if klass
@@ -108,13 +107,13 @@ class Thor::Group
108
107
  # invoked. The block receives two parameters, an instance of the current
109
108
  # class and the klass to be invoked.
110
109
  #
111
- def invoke_from_option(*names, &block)
110
+ def invoke_from_option(*names, &block) # rubocop:disable MethodLength
112
111
  options = names.last.is_a?(Hash) ? names.pop : {}
113
112
  verbose = options.fetch(:verbose, :white)
114
113
 
115
114
  names.each do |name|
116
115
  unless class_options.key?(name)
117
- raise ArgumentError, "You have to define the option #{name.inspect} " <<
116
+ fail ArgumentError, "You have to define the option #{name.inspect} " <<
118
117
  "before setting invoke_from_option."
119
118
  end
120
119
 
@@ -122,7 +121,7 @@ class Thor::Group
122
121
  invocation_blocks[name] = block if block_given?
123
122
 
124
123
  class_eval <<-METHOD, __FILE__, __LINE__
125
- def _invoke_from_option_#{name.to_s.gsub(/\W/, '_')}
124
+ def _invoke_from_option_#{name.to_s.gsub(/\W/, "_")}
126
125
  return unless options[#{name.inspect}]
127
126
 
128
127
  value = options[#{name.inspect}]
@@ -159,7 +158,7 @@ class Thor::Group
159
158
  # Overwrite class options help to allow invoked generators options to be
160
159
  # shown recursively when invoking a generator.
161
160
  #
162
- def class_options_help(shell, groups={}) #:nodoc:
161
+ def class_options_help(shell, groups = {}) #:nodoc:
163
162
  get_options_from_invocations(groups, class_options) do |klass|
164
163
  klass.send(:get_options_from_invocations, groups, class_options)
165
164
  end
@@ -170,7 +169,7 @@ class Thor::Group
170
169
  # options are added to group_options hash. Options that already exists
171
170
  # in base_options are not added twice.
172
171
  #
173
- def get_options_from_invocations(group_options, base_options) #:nodoc:
172
+ def get_options_from_invocations(group_options, base_options) #:nodoc: # rubocop:disable MethodLength
174
173
  invocations.each do |name, from_option|
175
174
  value = if from_option
176
175
  option = class_options[name]
@@ -200,70 +199,70 @@ class Thor::Group
200
199
  def printable_commands(*)
201
200
  item = []
202
201
  item << banner
203
- item << (desc ? "# #{desc.gsub(/\s+/m,' ')}" : "")
202
+ item << (desc ? "# #{desc.gsub(/\s+/m, ' ')}" : "")
204
203
  [item]
205
204
  end
206
- alias printable_tasks printable_commands
205
+ alias_method :printable_tasks, :printable_commands
207
206
 
208
207
  def handle_argument_error(command, error, args, arity) #:nodoc:
209
208
  msg = "#{basename} #{command.name} takes #{arity} argument"
210
209
  msg << "s" if arity > 1
211
210
  msg << ", but it should not."
212
- raise error, msg
211
+ fail error, msg
213
212
  end
214
213
 
215
- protected
214
+ protected
216
215
 
217
- # The method responsible for dispatching given the args.
218
- def dispatch(command, given_args, given_opts, config) #:nodoc:
219
- if Thor::HELP_MAPPINGS.include?(given_args.first)
220
- help(config[:shell])
221
- return
222
- end
216
+ # The method responsible for dispatching given the args.
217
+ def dispatch(command, given_args, given_opts, config) #:nodoc:
218
+ if Thor::HELP_MAPPINGS.include?(given_args.first)
219
+ help(config[:shell])
220
+ return
221
+ end
223
222
 
224
- args, opts = Thor::Options.split(given_args)
225
- opts = given_opts || opts
223
+ args, opts = Thor::Options.split(given_args)
224
+ opts = given_opts || opts
226
225
 
227
- instance = new(args, opts, config)
228
- yield instance if block_given?
226
+ instance = new(args, opts, config)
227
+ yield instance if block_given?
229
228
 
230
- if command
231
- instance.invoke_command(all_commands[command])
232
- else
233
- instance.invoke_all
234
- end
229
+ if command
230
+ instance.invoke_command(all_commands[command])
231
+ else
232
+ instance.invoke_all
235
233
  end
234
+ end
236
235
 
237
- # The banner for this class. You can customize it if you are invoking the
238
- # thor class by another ways which is not the Thor::Runner.
239
- def banner
240
- "#{basename} #{self_command.formatted_usage(self, false)}"
241
- end
236
+ # The banner for this class. You can customize it if you are invoking the
237
+ # thor class by another ways which is not the Thor::Runner.
238
+ def banner
239
+ "#{basename} #{self_command.formatted_usage(self, false)}"
240
+ end
242
241
 
243
- # Represents the whole class as a command.
244
- def self_command #:nodoc:
245
- Thor::DynamicCommand.new(self.namespace, class_options)
246
- end
247
- alias self_task self_command
242
+ # Represents the whole class as a command.
243
+ def self_command #:nodoc:
244
+ Thor::DynamicCommand.new(namespace, class_options)
245
+ end
246
+ alias_method :self_task, :self_command
248
247
 
249
- def baseclass #:nodoc:
250
- Thor::Group
251
- end
248
+ def baseclass #:nodoc:
249
+ Thor::Group
250
+ end
252
251
 
253
- def create_command(meth) #:nodoc:
254
- commands[meth.to_s] = Thor::Command.new(meth, nil, nil, nil, nil)
255
- true
256
- end
257
- alias create_task create_command
252
+ def create_command(meth) #:nodoc:
253
+ commands[meth.to_s] = Thor::Command.new(meth, nil, nil, nil, nil)
254
+ true
255
+ end
256
+ alias_method :create_task, :create_command
258
257
  end
259
258
 
260
259
  include Thor::Base
261
260
 
262
- protected
261
+ protected
263
262
 
264
263
  # Shortcut to invoke with padding and block handling. Use internally by
265
264
  # invoke and invoke_from_option class methods.
266
- def _invoke_for_class_method(klass, command=nil, *args, &block) #:nodoc:
265
+ def _invoke_for_class_method(klass, command = nil, *args, &block) #:nodoc:
267
266
  with_padding do
268
267
  if block
269
268
  case block.arity