Module: Toys::Context::Key

Defined in:
lib/toys/context.rb

Overview

Well-known context keys.

This module is mixed into the runtime context. This means you can reference any of these constants directly from your run method.

Example

tool "my-name" do
  def run
    # TOOL_NAME is available here.
    puts "My name is #{get(TOOL_NAME)}"
  end
end

Constant Summary collapse

ARGS =

Context key for the argument list passed to the current tool. Value is an array of strings.

Returns:

  • (Object)
::Object.new.freeze
CLI =

Context key for the currently running Toys::CLI. You can use the value to run other tools from your tool by calling Toys::CLI#run.

Returns:

  • (Object)
::Object.new.freeze
CONTEXT_DIRECTORY =

Context key for the context directory path. The value is a string

Returns:

  • (Object)
::Object.new.freeze
DELEGATED_FROM =

Context key for the context from which the current call was delegated. The value is either another context object, or nil if the current call is not delegated.

Returns:

  • (Object)
::Object.new.freeze
LOGGER =

Context key for the active Logger object.

Returns:

  • (Object)
::Object.new.freeze
TOOL =

Context key for the ToolDefinition object being executed.

Returns:

  • (Object)
::Object.new.freeze
TOOL_NAME =

Context key for the full name of the tool being executed. Value is an array of strings.

Returns:

  • (Object)
::Object.new.freeze
TOOL_SOURCE =

Context key for the SourceInfo describing the source of this tool.

Returns:

  • (Object)
::Object.new.freeze
UNMATCHED_ARGS =

Context key for all unmatched args in order. The value is an array of strings.

Returns:

  • (Object)
::Object.new.freeze
UNMATCHED_FLAGS =

Context key for unmatched flags. The value is an array of strings.

Returns:

  • (Object)
::Object.new.freeze
UNMATCHED_POSITIONAL =

Context key for unmatched positional args. The value is an array of strings.

Returns:

  • (Object)
::Object.new.freeze
USAGE_ERRORS =

Context key for the list of usage errors raised. The value is an array of ArgParser::UsageError.

Returns:

  • (Object)
::Object.new.freeze
VERBOSITY =

Context key for the verbosity value. The value is an integer defaulting to 0, with higher values meaning more verbose and lower meaning more quiet.

Returns:

  • (Object)
::Object.new.freeze