Class: Harnex::TelemetryCommand
- Inherits:
-
Object
- Object
- Harnex::TelemetryCommand
- Defined in:
- lib/harnex/commands/telemetry.rb
Constant Summary collapse
- COMMANDS =
%w[assert-canonical reconcile].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ TelemetryCommand
constructor
A new instance of TelemetryCommand.
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ TelemetryCommand
Returns a new instance of TelemetryCommand.
24 25 26 |
# File 'lib/harnex/commands/telemetry.rb', line 24 def initialize(argv) @argv = argv.dup end |
Class Method Details
.usage(program_name = "harnex telemetry") ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/harnex/commands/telemetry.rb', line 8 def self.usage(program_name = "harnex telemetry") <<~TEXT Usage: #{program_name} assert-canonical [--canonical PATH | --global] [--source PATH] [--json] #{program_name} reconcile [--canonical PATH | --global] --source PATH [--apply] [--json] Options: --canonical PATH Canonical dispatch JSONL path --global Use the global harnex dispatch JSONL --source PATH Source JSONL file or directory; repeatable --apply Append missing records when reconciling --json Emit JSON report -h, --help Show this help TEXT end |
Instance Method Details
#run ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/harnex/commands/telemetry.rb', line 28 def run command = @argv.shift case command when nil, "-h", "--help" puts self.class.usage 0 when *COMMANDS = (command, @argv) if [:help] puts self.class.usage return 0 end (command, ) result = TelemetryReconciler.new( command: command, canonical: canonical_path(), sources: [:sources], apply: command == "reconcile" && [:apply] ).run if [:json] puts JSON.generate(result.report) else puts render_human(result.report) end result.exitstatus else raise OptionParser::ParseError, "unknown telemetry subcommand #{command.inspect}" end end |