Class: CSVPlusPlus::CLI

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/csv_plus_plus/cli.rb

Overview

Handle running the application with the supported CLIFlags

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCLI

Initialize and parse the CLI flags provided to the program



30
31
32
33
34
35
# File 'lib/csv_plus_plus/cli.rb', line 30

def initialize
  opts = parse_options

  @source_code = ::T.let(::CSVPlusPlus::SourceCode.new(source_code_filename), ::CSVPlusPlus::SourceCode)
  @options = ::T.let(apply_options(opts), ::CSVPlusPlus::Options::Options)
end

Instance Attribute Details

#optionsOptions

The parsed CLI options

Returns:

  • (Options)

    the current value of options



8
9
10
# File 'lib/csv_plus_plus/cli.rb', line 8

def options
  @options
end

#source_codeObject

Returns the value of attribute source_code.



15
16
17
# File 'lib/csv_plus_plus/cli.rb', line 15

def source_code
  @source_code
end

Class Method Details

.launch_compiler!CLI

Handle CLI flags and launch the compiler

Returns:



21
22
23
24
25
26
# File 'lib/csv_plus_plus/cli.rb', line 21

def self.launch_compiler!
  new.main
rescue ::StandardError => e
  warn(e.message)
  exit(1)
end

Instance Method Details

#mainObject

Compile the given template using the given CLI flags



39
40
41
# File 'lib/csv_plus_plus/cli.rb', line 39

def main
  ::CSVPlusPlus.cli_compile(source_code, options)
end