Class: Harnex::Doctor

Inherits:
Object
  • Object
show all
Defined in:
lib/harnex/commands/doctor.rb

Constant Summary collapse

MIN_CODEX_VERSION =
Gem::Version.new("0.128.0")

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv = []) ⇒ Doctor

Returns a new instance of Doctor.



18
19
20
# File 'lib/harnex/commands/doctor.rb', line 18

def initialize(argv = [])
  @argv = argv.dup
end

Class Method Details

.usageObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/harnex/commands/doctor.rb', line 7

def self.usage
  <<~TEXT
    Usage: harnex doctor

    Runs preflight checks for harnex's adapter dependencies.
    Currently verifies that Codex CLI is installed and at version
    >= #{MIN_CODEX_VERSION} (required for the JSON-RPC `app-server`
    adapter).
  TEXT
end

Instance Method Details

#runObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/harnex/commands/doctor.rb', line 22

def run
  if @argv.include?("-h") || @argv.include?("--help")
    puts self.class.usage
    return 0
  end

  checks = [check_codex]
  summary = {
    ok: checks.all? { |c| c[:ok] },
    checks: checks
  }
  puts JSON.generate(summary)
  summary[:ok] ? 0 : 1
end