Class: Toys::Tool

Inherits:
Context show all
Defined in:
lib/toys/dsl/base.rb

Overview

Base class for defining tools

This base class provides an alternative to the DSL::Tool#tool directive for defining tools in the Toys DSL. Creating a subclass of Toys::Tool will create a tool whose name is the "kebab-case" of the class name. Subclasses can be created only in the context of a tool configuration DSL. Furthermore, a class-defined tool can be created only at the top level of a configuration file, or within another class-defined tool. It cannot be a subtool of a tool block.

Example

class FooBar < Toys::Tool
  desc "This is a tool called foo-bar"

  def run
    puts "foo-bar called"
  end
end

Method Summary

Methods inherited from Context

#[], #[]=, #args, #cli, #context_directory, #exit, exit, #find_data, #logger, #options, #set, #tool_name, #tool_source, #usage_errors, #verbosity