Class: Agentilda::CLI::Agents::Describe
- Inherits:
-
Dry::CLI::Command
- Object
- Dry::CLI::Command
- Agentilda::CLI::Agents::Describe
- Includes:
- UI
- Defined in:
- lib/agentilda/cli/agents/subcommands/describe.rb
Overview
agentilda agents describe [NAME]
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
- #call(name: nil, mdfried: false, **_options) ⇒ void
-
#initialize(agents: Agentilda::Agents.new, viewer: Viewer.new) ⇒ Describe
constructor
The registry instantiates commands bare, so both collaborators default to the real thing; the suite hands in its own to keep viewers from opening on the box running it.
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
Constructor Details
#initialize(agents: Agentilda::Agents.new, viewer: Viewer.new) ⇒ Describe
The registry instantiates commands bare, so both collaborators default to the real thing; the suite hands in its own to keep viewers from opening on the box running it.
31 32 33 34 35 |
# File 'lib/agentilda/cli/agents/subcommands/describe.rb', line 31 def initialize(agents: Agentilda::Agents.new, viewer: Viewer.new) super() @agents = agents @viewer = viewer end |
Instance Method Details
#call(name: nil, mdfried: false, **_options) ⇒ void
This method returns an undefined value.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/agentilda/cli/agents/subcommands/describe.rb', line 40 def call(name: nil, mdfried: false, **) agents = @agents found = name ? agents.match(name) : agents.all if found.empty? known = agents.all.map(&:name).join(", ") raise Error, name ? "No agent matches #{name}. Known: #{known}" : "No agent definitions in #{agents.dir}" end # A fragment that fits several agents is a question, not an order: # opening all of them would bury the one that was meant. raise Error, "#{name} could be any of #{found.map(&:name).join(", ")} — say which" if name && found.size > 1 paths = found.map(&:path) mdfried ? @viewer.mdfried(paths) : @viewer.open(paths) rescue Agentilda::Error => e error(e.) exit 65 end |