Class Bundler::Thor
In: lib/bundler/vendor/thor/lib/thor.rb
lib/bundler/vendor/thor/lib/thor/version.rb
lib/bundler/vendor/thor/lib/thor/rake_compat.rb
lib/bundler/vendor/thor/lib/thor/base.rb
lib/bundler/vendor/thor/lib/thor/parser/options.rb
lib/bundler/vendor/thor/lib/thor/parser/option.rb
lib/bundler/vendor/thor/lib/thor/parser/argument.rb
lib/bundler/vendor/thor/lib/thor/parser/arguments.rb
lib/bundler/vendor/thor/lib/thor/shell/html.rb
lib/bundler/vendor/thor/lib/thor/shell/color.rb
lib/bundler/vendor/thor/lib/thor/shell/basic.rb
lib/bundler/vendor/thor/lib/thor/util.rb
lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb
lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb
lib/bundler/vendor/thor/lib/thor/line_editor.rb
lib/bundler/vendor/thor/lib/thor/shell.rb
lib/bundler/vendor/thor/lib/thor/invocation.rb
lib/bundler/vendor/thor/lib/thor/actions.rb
lib/bundler/vendor/thor/lib/thor/actions/create_file.rb
lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb
lib/bundler/vendor/thor/lib/thor/actions/create_link.rb
lib/bundler/vendor/thor/lib/thor/actions/directory.rb
lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
lib/bundler/vendor/thor/lib/thor/command.rb
lib/bundler/vendor/thor/lib/thor/error.rb
lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb
lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb
Parent: Object

Methods

Included Modules

Bundler::Thor::Base

Classes and Modules

Module Bundler::Thor::Actions
Module Bundler::Thor::Base
Module Bundler::Thor::Invocation
Module Bundler::Thor::LineEditor
Module Bundler::Thor::RakeCompat
Module Bundler::Thor::Shell
Module Bundler::Thor::Util
Class Bundler::Thor::AmbiguousCommandError
Class Bundler::Thor::Command
Class Bundler::Thor::DynamicCommand
Class Bundler::Thor::Error
Class Bundler::Thor::Group
Class Bundler::Thor::HiddenCommand
Class Bundler::Thor::InvocationError
Class Bundler::Thor::MalformattedArgumentError
Class Bundler::Thor::RequiredArgumentMissingError
Class Bundler::Thor::UndefinedCommandError
Class Bundler::Thor::UnknownArgumentError

Constants

VERSION = "0.19.1"
HELP_MAPPINGS = %w[-h -? --help -D]   Shortcuts for help.
THOR_RESERVED_WORDS = %w[invoke shell options behavior root destination_root relative_root action add_file create_file in_root inside run run_ruby_script]   Bundler::Thor methods that should not be overwritten by the user.
TEMPLATE_EXTNAME = ".tt"
Task = Command # rubocop:disable ConstantName
HiddenTask = HiddenCommand # rubocop:disable ConstantName
DynamicTask = DynamicCommand # rubocop:disable ConstantName
UndefinedTaskError = UndefinedCommandError # rubocop:disable ConstantName
AmbiguousTaskError = AmbiguousCommandError # rubocop:disable ConstantName

External Aliases

default_command -> default_task
method_options -> options
method_option -> option
command_help -> task_help
printable_commands -> printable_tasks
subcommands -> subtasks
subcommand -> subtask
create_command -> create_task
retrieve_command_name -> retrieve_task_name
normalize_command_name -> normalize_task_name
find_command_possibilities -> find_task_possibilities
subcommand_help -> subtask_help

Public Class methods

Extend check unknown options to accept a hash of conditions.

Parameters

options<Hash>: A hash containing :only and/or :except keys

Prints help information for the given command.

Parameters

shell<Bundler::Thor::Shell> command_name<String>

Sets the default command when thor is executed without an explicit command to be called.

Parameters

meth<Symbol>:name of the default command

Defines the usage and the description of the next command.

Parameters

usage<String> description<String> options<String>

Prints help information for this class.

Parameters

shell<Bundler::Thor::Shell>

Defines the long description of the next command.

Parameters

long description<String>

Maps an input to a command. If you define:

  map "-T" => "list"

Running:

  thor -T

Will invoke the list command.

Parameters

Hash[String|Array => Symbol]:Maps the string or the strings in the array to the given command.

Adds an option to the set of method options. If :for is given as option, it allows you to change the options from a previous defined command.

  def previous_command
    # magic
  end

  method_option :foo => :bar, :for => :previous_command

  def next_command
    # magic
  end

Parameters

name<Symbol>:The name of the argument.
options<Hash>:Described below.

Options

:desc - Description for the argument. :required - If the argument is required or not. :default - Default value for this argument. It cannot be required and have default values. :aliases - Aliases for this option. :type - The type of the argument, can be :string, :hash, :array, :numeric or :boolean. :banner - String to show on usage notes. :hide - If you want to hide this option from the help.

Declares the options for the next command to be declared.

Parameters

Hash[Symbol => Object]:The hash key is the name of the option and the value

is the type of the option. Can be :string, :array, :hash, :boolean, :numeric or :required (string). If you give a value, the type of the value is used.

Allows for custom "Command" package naming.

Parameters

name<String> options<Hash>

Returns commands ready to be printed.

Registers another Bundler::Thor subclass as a command.

Parameters

klass<Class>:Bundler::Thor subclass to register
command<String>:Subcommand name to use
usage<String>:Short usage for the subcommand
description<String>:Description for the subcommand

Stop parsing of options as soon as an unknown option or a regular argument is encountered. All remaining arguments are passed to the command. This is useful if you have a command that can receive arbitrary additional options, and where those additional options should not be handled by Bundler::Thor.

Example

To better understand how this is useful, let‘s consider a command that calls an external command. A user may want to pass arbitrary options and arguments to that command. The command itself also accepts some options, which should be handled by Bundler::Thor.

  class_option "verbose",  :type => :boolean
  stop_on_unknown_option! :exec
  check_unknown_options!  :except => :exec

  desc "exec", "Run a shell command"
  def exec(*args)
    puts "diagnostic output" if options[:verbose]
    Kernel.exec(*args)
  end

Here exec can be called with +—verbose+ to get diagnostic output, e.g.:

  $ thor exec --verbose echo foo
  diagnostic output
  foo

But if +—verbose+ is given after echo, it is passed to echo instead:

  $ thor exec echo --verbose foo
  --verbose foo

Parameters

Symbol …:A list of commands that should be affected.

Protected Class methods

The banner for this class. You can customize it if you are invoking the thor class by another ways which is not the Bundler::Thor::Runner. It receives the command that is going to be invoked and a boolean which indicates if the namespace should be displayed as arguments.

this is the logic that takes the command name passed in by the user and determines whether it is an unambiguous substrings of a command or alias name.

Public Instance methods

[Validate]