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

Class Method Details

.exit_on_failure?Boolean

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

Returns:

  • (Boolean)


195
196
197
# File 'lib/inferno/apps/cli/main.rb', line 195

def self.exit_on_failure?
  true
end

Instance Method Details

#consoleObject



52
53
54
55
# File 'lib/inferno/apps/cli/main.rb', line 52

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

#evaluate(ig_path) ⇒ Object



47
48
49
# File 'lib/inferno/apps/cli/main.rb', line 47

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

#executeObject



189
190
191
192
# File 'lib/inferno/apps/cli/main.rb', line 189

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

#migrateObject



58
59
60
# File 'lib/inferno/apps/cli/main.rb', line 58

def migrate
  Migration.new.run
end

#startObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/inferno/apps/cli/main.rb', line 67

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



90
91
92
# File 'lib/inferno/apps/cli/main.rb', line 90

def suites
  Suites.new.run
end

#versionObject



103
104
105
# File 'lib/inferno/apps/cli/main.rb', line 103

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