Class: Polytrix::Command::Base

Inherits:
Object
  • Object
show all
Includes:
DefaultLogger, Logging, Util::FileSystem
Defined in:
lib/polytrix/command.rb

Overview

rubocop:disable ClassLength

Direct Known Subclasses

Action, List, Show, Test

Instance Method Summary collapse

Methods included from Util::FileSystem

#find_file, #relativize

Methods included from Util::String

included

Methods included from Util::String::ClassMethods

#ansi2html, #escape_html, #highlight, #slugify

Methods included from DefaultLogger

included

Methods included from DefaultLogger::ClassMethods

#logger

Constructor Details

#initialize(cmd_args, cmd_options, options = {}) ⇒ Base

Contstructs a new Command object.

Parameters:

  • cmd_args (Array)

    remainder of the arguments from processed ARGV

  • cmd_options (Hash)

    hash of Thor options

  • options (Hash) (defaults to: {})

    configuration options

Options Hash (options):

  • :action (String)

    action to take, usually corresponding to the subcommand name (default: ‘nil`)

  • :help (proc)

    a callable that displays help for the command

  • :test_dir (Config)

    a Config object (default: ‘nil`)

  • :loader (Loader)

    a Loader object (default: ‘nil`)

  • :shell (String)

    a Thor shell object



22
23
24
25
26
27
28
29
30
31
# File 'lib/polytrix/command.rb', line 22

def initialize(cmd_args, cmd_options, options = {})
  @args = cmd_args
  @options = cmd_options
  @action = options.fetch(:action, nil)
  @help = options.fetch(:help, -> { 'No help provided' })
  @manifest_file = options.fetch('manifest', nil)
  @loader = options.fetch(:loader, nil)
  @shell = options.fetch(:shell)
  @queue = Queue.new
end