Class: CovLoupe::Commands::BaseCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/cov_loupe/commands/base_command.rb

Overview

Base class for CLI subcommands. Provides shared behavior:

  • Lazy model initialization via config.model_options
  • Path-based argument handling with automatic error conversion
  • Structured format output (JSON, YAML, etc.) with optional source code display
  • Extra argument validation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cli_context) ⇒ BaseCommand

Returns a new instance of BaseCommand.



18
19
20
21
22
23
24
# File 'lib/cov_loupe/commands/base_command.rb', line 18

def initialize(cli_context)
  @cli = cli_context
  @config = cli_context.config
  @source_formatter = Formatters::SourceFormatter.new(
    **config.formatter_options
  )
end

Instance Attribute Details

#cliObject (readonly)

Returns the value of attribute cli.



26
27
28
# File 'lib/cov_loupe/commands/base_command.rb', line 26

def cli
  @cli
end

#configObject (readonly)

Returns the value of attribute config.



26
27
28
# File 'lib/cov_loupe/commands/base_command.rb', line 26

def config
  @config
end

#source_formatterObject (readonly)

Returns the value of attribute source_formatter.



26
27
28
# File 'lib/cov_loupe/commands/base_command.rb', line 26

def source_formatter
  @source_formatter
end