Class: Ace::Hitl::CLI::Commands::Ask

Inherits:
Support::Cli::Command
  • Object
show all
Includes:
Support::Cli::Base
Defined in:
lib/ace/hitl/cli/commands/ask.rb

Instance Method Summary collapse

Instance Method Details

#call(question:, **options) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/ace/hitl/cli/commands/ask.rb', line 36

def call(question:, **options)
  effect = build_effect(options)
  validate_effect!(effect)

  work = require_work!(options)
  attempt = require_attempt!(options)
  provider = resolve_provider(options[:provider])
  ref = capture_ref

  result = provider.ask(
    question: question,
    title: options[:title],
    ref: ref,
    work: work,
    attempt: attempt,
    project: options[:project] || Providers::Lab::DEFAULT_PROJECT,
    harness: options[:harness] || Providers::Lab::DEFAULT_HARNESS,
    plan: options[:plan] || Providers::Lab::DEFAULT_PLAN,
    effect: effect
  )

  puts "HITL event: #{result.event_id}"
  puts "Provider: #{Providers::Lab::PROVIDER_NAME} (ref #{ref.session}/#{ref.pane}, #{Providers::Ref::SCHEMA})"
  puts "Lab request: #{result.request_id}"
rescue Providers::ProviderUnavailableError => e
  raise_cli_error(e.message)
end