Class: Bogo::Cli::Command
- Inherits:
-
Object
- Object
- Bogo::Cli::Command
- Includes:
- Memoization
- Defined in:
- lib/bogo-cli/command.rb
Overview
Abstract command class
Instance Attribute Summary collapse
-
#arguments ⇒ Array
readonly
Cli arguments.
-
#options ⇒ Hash
readonly
Options.
- #ui ⇒ Ui readonly
Instance Method Summary collapse
-
#execute! ⇒ TrueClass
Execute the command.
-
#initialize(cli_opts, args) ⇒ self
constructor
Build new command instance.
Constructor Details
#initialize(cli_opts, args) ⇒ self
Build new command instance
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bogo-cli/command.rb', line 22 def initialize(cli_opts, args) = cli_opts.to_hash.to_smash(:snake) @arguments = args ui_args = Smash.new( :app_name => .fetch(:app_name, self.class.name.split('::').first ) ).merge(cli_opts.to_smash).merge(opts) @ui = .delete(:ui) || Ui.new(ui_args) load_config! end |
Instance Attribute Details
#arguments ⇒ Array (readonly)
15 16 17 |
# File 'lib/bogo-cli/command.rb', line 15 def arguments @arguments end |
#options ⇒ Hash (readonly)
13 14 15 |
# File 'lib/bogo-cli/command.rb', line 13 def end |
#ui ⇒ Ui (readonly)
17 18 19 |
# File 'lib/bogo-cli/command.rb', line 17 def ui @ui end |
Instance Method Details
#execute! ⇒ TrueClass
Execute the command
37 38 39 |
# File 'lib/bogo-cli/command.rb', line 37 def execute! raise NotImplementedError end |