Class: Nymphia::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/nymphia/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.



10
11
12
13
# File 'lib/nymphia/cli.rb', line 10

def initialize(argv)
  @argv = argv.dup
  parser.parse!(@argv)
end

Class Method Details

.start(argv) ⇒ Object



6
7
8
# File 'lib/nymphia/cli.rb', line 6

def self.start(argv)
  new(argv).run
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/nymphia/cli.rb', line 15

def run
  validate_args!

  dsl_code_file = File.open(@file_path)
  absolute_dsl_file_path = File.absolute_path(dsl_code_file.path)
  dsl_code = dsl_code_file.read

  dsl = Nymphia::DSL.new(dsl_code, absolute_dsl_file_path)
  dsl.compile

  if @output_file_path
    dsl.render(File.open(@output_file_path, 'w'))
  else
    dsl.render(STDOUT)
  end
end