Method: Bundler::Thor.subcommand

Defined in:
lib/bundler/vendor/thor/lib/thor.rb

.subcommand(subcommand, subcommand_class) ⇒ Object Also known as: subtask

[View source]

329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/bundler/vendor/thor/lib/thor.rb', line 329

def subcommand(subcommand, subcommand_class)
  subcommands << subcommand.to_s
  subcommand_class.subcommand_help subcommand
  subcommand_classes[subcommand.to_s] = subcommand_class

  define_method(subcommand) do |*args|
    args, opts = Bundler::Thor::Arguments.split(args)
    invoke_args = [args, opts, {invoked_via_subcommand: true, class_options: options}]
    invoke_args.unshift "help" if opts.delete("--help") || opts.delete("-h")
    invoke subcommand_class, *invoke_args
  end
  subcommand_class.commands.each do |_meth, command|
    command.ancestor_name = subcommand
  end
end