Class: Ace::Hitl::CLI::Commands::Create

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

Instance Method Summary collapse

Instance Method Details

#call(title: nil, **options) ⇒ Object



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/ace/hitl/cli/commands/create.rb', line 29

def call(title: nil, **options)
  unless title && !title.strip.empty?
    raise Ace::Support::Cli::Error.new("Title required")
  end

  kind = options[:kind]
  validate_kind!(kind) if kind

  questions = Array(options[:question]).map(&:strip).reject(&:empty?)
  tags = parse_tags(options[:tags])

  manager = Ace::Hitl::Organisms::HitlManager.new
  event = manager.create(
    title,
    kind: kind,
    questions: questions,
    tags: tags,
    assignment: options[:assignment],
    step: options[:step],
    step_name: options[:"step-name"],
    resume_instructions: options[:resume],
    move_to: options[:"move-to"]
  )

  folder_info = event.special_folder ? " (#{event.special_folder})" : ""
  puts "HITL event created: #{event.id} #{event.title}#{folder_info}"
  puts "  Path: #{event.file_path}"
end