Class: Slk::Commands::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/slk/commands/base.rb

Overview

Base class for all CLI commands with option parsing and output helpers rubocop:disable Metrics/ClassLength

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, runner:) ⇒ Base

Returns a new instance of Base.



10
11
12
13
14
# File 'lib/slk/commands/base.rb', line 10

def initialize(args, runner:)
  @runner = runner
  @options = default_options
  @positional_args = parse_options(args)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/slk/commands/base.rb', line 8

def options
  @options
end

#positional_argsObject (readonly)

Returns the value of attribute positional_args.



8
9
10
# File 'lib/slk/commands/base.rb', line 8

def positional_args
  @positional_args
end

#runnerObject (readonly)

Returns the value of attribute runner.



8
9
10
# File 'lib/slk/commands/base.rb', line 8

def runner
  @runner
end

Instance Method Details

#executeObject

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/slk/commands/base.rb', line 16

def execute
  raise NotImplementedError, 'Subclass must implement #execute'
end