Class: Agentilda::CLI::Create

Inherits:
Base
  • Object
show all
Defined in:
lib/agentilda/cli/create/create.rb

Overview

agentilda create <words…> — backs /spec-create.

Constant Summary

Constants included from UI

UI::MAX_WIDTH, UI::METER_WIDTH, UI::MIN_WIDTH, UI::NO_FAILURE, UI::NO_FIELDS, UI::NO_TIMEOUT, UI::PROGRESS_THRESHOLD, UI::TIMER_WARNING, UI::TIMER_WIDTH

Instance Method Summary collapse

Methods inherited from Base

inherited

Methods included from UI

abbreviate, activity_for, animate?, box, box_height, color?, concurrently, countdown, default_jobs, display_width, elapsed, #error, fit, #info, line, log, logging_activity, meter, monotonic, once, paint, #paint, pastel, popup, report_line, reset!, said, #say, solo_spinner, spinning, stepping, #success, threaded, tty?, #warn, width

Instance Method Details

#call(words:, **options) ⇒ void

This method returns an undefined value.

Parameters:

  • words (Array<String>)
  • options (Hash)


61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/agentilda/cli/create/create.rb', line 61

def call(words:, **options)
  dir = options.fetch(:dir, Agentilda::PLANS_DIR)
  FileUtils.mkdir_p(dir)

  words, seed = resolve_seed(words, options)
  prs = fetch_prs(options)
  result =
    Creator.new(dir:).create(
      words:,
      after: options[:after],
      status: options[:status],
      prs:
    )

  result.either(
    ->(path) { created(path, prs, options, seed:) },
    ->(message) { refuse("Could not create the plan:\n#{message}", 65) }
  )
end