Class: XCRes::Command

Inherits:
Clamp::Command
  • Object
show all
Defined in:
lib/xcres/command/command.rb

Overview

Base class for commands

Direct Known Subclasses

MainCommand, ProjectCommand, VersionCommand

Logger collapse

Instance Method Summary collapse

Instance Method Details

#configure_loggerObject

Checks the configured option to configure the logger



49
50
51
52
53
54
55
56
# File 'lib/xcres/command/command.rb', line 49

def configure_logger
  logger.silent = silent?
  logger.colored = ansi?
  if verbose?
    logger.verbose = verbose?
    log 'Verbose mode is enabled.'
  end
end

#executeObject



28
29
30
31
# File 'lib/xcres/command/command.rb', line 28

def execute
  # Configure logger
  configure_logger
end

#loggerObject

Lazy-instantiate a logger



39
40
41
# File 'lib/xcres/command/command.rb', line 39

def logger
  @logger ||= XCRes::Logger.new
end

#run(arguments) ⇒ Object

Run the command, with the specified arguments.

This calls #parse to process the command-line arguments, then delegates to #execute.

Parameters:

  • arguments (Array<String>)

    command-line arguments



19
20
21
22
23
24
25
26
# File 'lib/xcres/command/command.rb', line 19

def run(arguments)
  super
rescue Clamp::HelpWanted => e
  raise e # Clamp will handle this for us
rescue StandardError => error
  fail error
  exit 1
end