Class: Inferno::CLI::Main

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

Constant Summary collapse

EXECUTE_HELP =
<<~END_OF_HELP.freeze
  Run Inferno tests in the command line. Exits with 0 only if test entity passes.
  Must be run with test kit as working directory.

  You must have background services running: `bundle exec inferno services start`

  You can view suite ids with: `bundle exec inferno suites`

  You can select an output format with the `--outputter` option. Current outputters
  are console (default), plain, quiet, and json. JSON-formatted output will copy
  Inferno's REST API: https://inferno-framework.github.io/inferno-core/api-docs/#/Result.

  Examples:

      (These examples only work from within the inferno_core directory).

      `bundle exec inferno execute --suite dev_validator \
                                  --inputs "url:https://hapi.fhir.org/baseR4" \
                                           patient_id:1234321`
      => Outputs test results

      `bundle exec inferno execute --suite dev_validator \
                                   --inputs "url:https://hapi.fhir.org/baseR4" \
                                            patient_id:1234321 \
                                   --tests 1.01 1.02`
      => Run specific tests from suite

      `bundle exec inferno execute --suite dev_validator \
                                   --inputs "url:https://hapi.fhir.org/baseR4" \
                                            patient_id:1234321 \
                                   --outputter json`
      => Outputs test results in JSON
END_OF_HELP

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = [], local_options = {}, config = {}) ⇒ Main

Returns a new instance of Main.



17
18
19
20
21
22
# File 'lib/inferno/apps/cli/main.rb', line 17

def initialize(args = [], local_options = {}, config = {})
  super
  return unless @options[:inferno_base_url]

  @options = @options.merge(inferno_base_url: "#{@options[:inferno_base_url].delete_suffix('/')}/")
end

Class Method Details

.exit_on_failure?Boolean

github.com/rails/thor/issues/244 - Make Thor exit(1) on Errors/Exceptions

Returns:

  • (Boolean)


256
257
258
# File 'lib/inferno/apps/cli/main.rb', line 256

def self.exit_on_failure?
  true
end

Instance Method Details

#consoleObject



68
69
70
71
# File 'lib/inferno/apps/cli/main.rb', line 68

def console
  Migration.new.run(Logger::INFO)
  Console.new.run
end

#evaluate(ig_path) ⇒ Object



63
64
65
# File 'lib/inferno/apps/cli/main.rb', line 63

def evaluate(ig_path)
  Evaluate.new.run(ig_path, options[:data_path], options)
end

#executeObject



250
251
252
253
# File 'lib/inferno/apps/cli/main.rb', line 250

def execute
  Execute.boot_full_inferno
  Execute.new.run(options.dup) # dup to unfreeze Thor options
end

#execute_script(yaml_file) ⇒ Object



112
113
114
# File 'lib/inferno/apps/cli/main.rb', line 112

def execute_script(yaml_file)
  ExecuteScript.new(yaml_file, options).run
end

#migrateObject



74
75
76
# File 'lib/inferno/apps/cli/main.rb', line 74

def migrate
  Migration.new.run
end

#startObject



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/inferno/apps/cli/main.rb', line 124

def start
  Migration.new.run(Logger::INFO)

  without_bundler do
    command = 'foreman start --env=/dev/null'

    if `gem list -i foreman`.chomp == 'false'
      puts "You must install foreman with 'gem install foreman' prior to running Inferno."
    end

    if options[:watch]
      if `gem list -i rerun`.chomp == 'false'
        puts "You must install 'rerun' with 'gem install rerun' to restart on file changes."
      end

      command = "rerun \"#{command}\" --background"
    end

    exec command
  end
end

#suitesObject



147
148
149
150
151
152
153
# File 'lib/inferno/apps/cli/main.rb', line 147

def suites
  ENV['NO_DB'] = 'true'

  require_relative '../../../inferno'

  Suites.new.run
end

#versionObject



164
165
166
# File 'lib/inferno/apps/cli/main.rb', line 164

def version
  puts "Inferno Core v#{Inferno::VERSION}"
end