Class: Harnex::ArtifactReportCommand

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ ArtifactReportCommand

Returns a new instance of ArtifactReportCommand.



28
29
30
# File 'lib/harnex/commands/artifact_report.rb', line 28

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

Class Method Details

.usage(program_name = "harnex artifact-report") ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/harnex/commands/artifact_report.rb', line 6

def self.usage(program_name = "harnex artifact-report")
  <<~TEXT
    Usage:
      #{program_name} init PATH [--force]
      #{program_name} validate PATH [--final]

    Commands:
      init       Write a bounded harnex.artifact_report.v1 skeleton
      validate   Validate schema and field shapes without printing report data

    Options:
      --final    Require an accepted/no_change final outcome, passing proof,
                 and validation.final_reported=true
      --force    Replace an existing file during init
      -h, --help Show this help

    Both commands print machine-readable JSON. `validate` exits 0 only when
    the requested contract is satisfied; diagnostics contain field paths and
    shape errors, never report payloads or transcripts.
  TEXT
end

Instance Method Details

#runObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/harnex/commands/artifact_report.rb', line 32

def run
  command = @argv.shift
  case command
  when "init"
    run_init(@argv)
  when "validate"
    run_validate(@argv)
  when nil, "help", "-h", "--help"
    puts self.class.usage
    0
  else
    raise OptionParser::ParseError, "unknown artifact-report command #{command.inspect}"
  end
end