Class: Inferno::CLI::SuiteInputTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/inferno/apps/cli/suite_input_template.rb

Instance Method Summary collapse

Instance Method Details

#run(suite_id, options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/inferno/apps/cli/suite_input_template.rb', line 6

def run(suite_id, options)
  require_relative '../../../inferno'

  Inferno::Application.start(:suites)

  suite = Inferno::Repositories::TestSuites.new.find(suite_id)
  if suite.nil?
    puts "No Test Suite found with id: #{suite_id}"
    return 1
  end

  output = JSON.pretty_generate(Inferno::Utils::PresetTemplateGenerator.new(suite).generate)

  if options[:filename].present?
    path = File.join(Dir.pwd, 'config', 'presets', options[:filename])
    FileUtils.mkdir_p(File.dirname(path))

    File.open(path, 'w') { |f| f.puts(output) }
  else
    puts output
  end
end