Class: Chemicalml::Cli::Command
- Inherits:
-
Object
- Object
- Chemicalml::Cli::Command
- Defined in:
- lib/chemicalml/cli/command.rb
Overview
Base class for every command. Subclasses implement #run(options).
Each command receives a Chemicalml::Logger in its constructor.
When dispatched via Thor (the normal CLI path), the logger is
bridged to Thor's shell for coloured output. When invoked
directly (MyCommand.new.run(options)), the logger writes plain
text to $stderr.
Direct Known Subclasses
ConstraintsCommand, ConventionsCommand, DictionariesCommand, ElementsCommand, EnumsCommand, InfoCommand, InspectCommand, ValidateCommand
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(logger: Chemicalml::Logger.default) ⇒ Command
constructor
A new instance of Command.
- #run(_options = {}) ⇒ Object
Constructor Details
#initialize(logger: Chemicalml::Logger.default) ⇒ Command
Returns a new instance of Command.
18 19 20 |
# File 'lib/chemicalml/cli/command.rb', line 18 def initialize(logger: Chemicalml::Logger.default) @logger = logger end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
13 14 15 |
# File 'lib/chemicalml/cli/command.rb', line 13 def logger @logger end |
Class Method Details
.run(options = {}, logger: Chemicalml::Logger.default) ⇒ Object
23 24 25 |
# File 'lib/chemicalml/cli/command.rb', line 23 def run( = {}, logger: Chemicalml::Logger.default) new(logger: logger).run() end |
Instance Method Details
#run(_options = {}) ⇒ Object
28 29 30 |
# File 'lib/chemicalml/cli/command.rb', line 28 def run( = {}) raise NotImplementedError, "#{self.class} must implement #run" end |