Class: Bogo::Cli::Command

Inherits:
Object
  • Object
show all
Includes:
Memoization
Defined in:
lib/bogo-cli/command.rb

Overview

Abstract command class

Instance Attribute Summary collapse

Instance Method Summary collapse

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)
  @options = cli_opts.to_hash.to_smash(:snake)
  @arguments = args
  ui_args = Smash.new(
    :app_name => options.fetch(:app_name,
      self.class.name.split('::').first
    )
  ).merge(cli_opts.to_smash).merge(opts)
  @ui = options.delete(:ui) || Ui.new(ui_args)
  load_config!
end

Instance Attribute Details

#argumentsArray (readonly)



15
16
17
# File 'lib/bogo-cli/command.rb', line 15

def arguments
  @arguments
end

#optionsHash (readonly)



13
14
15
# File 'lib/bogo-cli/command.rb', line 13

def options
  @options
end

#uiUi (readonly)



17
18
19
# File 'lib/bogo-cli/command.rb', line 17

def ui
  @ui
end

Instance Method Details

#execute!TrueClass

Execute the command

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/bogo-cli/command.rb', line 37

def execute!
  raise NotImplementedError
end