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.
::Toys::UniqueKey.new("Toys::Context::Key::ARGS")
- CLI =
Context key for the currently running Toys::CLI. You can use the value to reconfigure the framework, for example by calling Toys::CLI#child to run a tool under modified settings. To run a sibling tool without reconfiguring anything, you can also use RUNNER instead. The value could be nil if a CLI is not present.
::Toys::UniqueKey.new("Toys::Context::Key::CLI")
- CONTEXT_DIRECTORY =
Context key for the context directory path. The value is a string.
::Toys::UniqueKey.new("Toys::Context::Key::CONTEXT_DIRECTORY")
- DELEGATED_FROM =
Context key for the context from which the current call was delegated. The value is either another context object, or
nilif the current call is not delegated. ::Toys::UniqueKey.new("Toys::Context::Key::DELEGATED_FROM")
- EXECUTABLE_NAME =
Context key for the executable name displayed in help text. The value is a String, provided by the Runner.
::Toys::UniqueKey.new("Toys::Context::Key::EXECUTABLE_NAME")
- LOADER =
Context key for the active
Loaderobject. ::Toys::UniqueKey.new("Toys::Context::Key::LOADER")
- LOGGER =
Context key for the active
Loggerobject. ::Toys::UniqueKey.new("Toys::Context::Key::LOGGER")
- RUNNER =
Context key for the Runner that is running the current tool. You can use the value to run other tools from your tool by calling Runner#run.
::Toys::UniqueKey.new("Toys::Context::Key::RUNNER")
- TOOL =
Context key for the ToolDefinition object being executed.
::Toys::UniqueKey.new("Toys::Context::Key::TOOL")
- TOOL_NAME =
Context key for the full name of the tool being executed. Value is an array of strings.
::Toys::UniqueKey.new("Toys::Context::Key::TOOL_NAME")
- TOOL_SOURCE =
Context key for the SourceInfo describing the source of this tool.
::Toys::UniqueKey.new("Toys::Context::Key::TOOL_SOURCE")
- UNMATCHED_ARGS =
Context key for all unmatched args in order. The value is an array of strings.
::Toys::UniqueKey.new("Toys::Context::Key::UNMATCHED_ARGS")
- UNMATCHED_FLAGS =
Context key for unmatched flags. The value is an array of strings.
::Toys::UniqueKey.new("Toys::Context::Key::UNMATCHED_FLAGS")
- UNMATCHED_POSITIONAL =
Context key for unmatched positional args. The value is an array of strings.
::Toys::UniqueKey.new("Toys::Context::Key::UNMATCHED_POSITIONAL")
- USAGE_ERRORS =
Context key for the list of usage errors raised. The value is an array of ArgParser::UsageError.
::Toys::UniqueKey.new("Toys::Context::Key::USAGE_ERRORS")
- 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.
::Toys::UniqueKey.new("Toys::Context::Key::VERBOSITY")