Class: XCRes::Command
- Inherits:
-
Clamp::Command
- Object
- Clamp::Command
- XCRes::Command
- Defined in:
- lib/xcres/command/command.rb
Overview
Base class for commands
Direct Known Subclasses
Logger collapse
-
#configure_logger ⇒ Object
Checks the configured option to configure the logger.
-
#logger ⇒ Object
Lazy-instantiate a logger.
Instance Method Summary collapse
- #execute ⇒ Object
-
#run(arguments) ⇒ Object
Run the command, with the specified arguments.
Instance Method Details
#configure_logger ⇒ Object
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 |
#execute ⇒ Object
28 29 30 31 |
# File 'lib/xcres/command/command.rb', line 28 def execute # Configure logger configure_logger end |
#logger ⇒ Object
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.
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 |