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

Methods

Included Modules

Thor::Base

Classes and Modules

Module Thor::Actions
Module Thor::Base
Module Thor::Invocation
Module Thor::RakeCompat
Module Thor::Shell
Module Thor::Util
Class Thor::DynamicTask
Class Thor::Error
Class Thor::Group
Class Thor::HiddenTask
Class Thor::InvocationError
Class Thor::MalformattedArgumentError
Class Thor::PrivateMethodEncodedError
Class Thor::RequiredArgumentMissingError
Class Thor::Task
Class Thor::UndefinedTaskError
Class Thor::UnknownArgumentError

Constants

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)   Thor methods that should not be overwritten by the user.
VERSION = "0.17.0"

External Aliases

method_options -> options
method_option -> option

Public Class methods

Extend check unknown options to accept a hash of conditions.

Parameters

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

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

Parameters

meth<Symbol>:name of the default task

Defines the usage and the description of the next task.

Parameters

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

Prints help information for this class.

Parameters

shell<Thor::Shell>

Defines the long description of the next task.

Parameters

long description<String>

Maps an input to a task. If you define:

  map "-T" => "list"

Running:

  thor -T

Will invoke the list task.

Parameters

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

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 task.

  def previous_task
    # magic
  end

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

  def next_task
    # 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 task 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.

Returns tasks ready to be printed.

Registers another Thor subclass as a command.

Parameters

klass<Class>: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 task. This is useful if you have a task that can receive arbitrary additional options, and where those additional options should not be handled by Thor.

Example

To better understand how this is useful, let‘s consider a task that calls an external command. A user may want to pass arbitrary options and arguments to that command. The task itself also accepts some options, which should be handled by 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 tasks that should be affected.

Prints help information for the given task.

Parameters

shell<Thor::Shell> task_name<String>

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 Thor::Runner. It receives the task 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 task name passed in by the user and determines whether it is an unambiguous substrings of a task or alias name.

Public Instance methods

[Validate]