Class: SwarmCLI::Commands::Run
- Inherits:
-
Object
- Object
- SwarmCLI::Commands::Run
- Defined in:
- lib/swarm_cli/commands/run.rb
Overview
Run command executes a swarm with the given configuration and prompt.
Supports both YAML (.yml, .yaml) and Ruby DSL (.rb) configuration files.
Usage:
swarm run config.yml -p "Build a REST API"
swarm run config.rb -p "Build a REST API"
echo "Build a REST API" | swarm run config.yml
swarm run config.yml -p "Task" --output-format json
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(options) ⇒ Run
constructor
A new instance of Run.
Constructor Details
#initialize(options) ⇒ Run
Returns a new instance of Run.
18 19 20 |
# File 'lib/swarm_cli/commands/run.rb', line 18 def initialize() @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/swarm_cli/commands/run.rb', line 16 def @options end |
Instance Method Details
#execute ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/swarm_cli/commands/run.rb', line 22 def execute # Validate options .validate! # Load swarm configuration swarm = load_swarm # Check if interactive mode (no prompt provided and stdin is a tty) if .interactive_mode? run_interactive_mode(swarm) else run_non_interactive_mode(swarm) end rescue SwarmSDK::ConfigurationError, SwarmSDK::AgentNotFoundError => e # Configuration errors - show user-friendly message handle_error(e, formatter: create_formatter) exit(1) rescue SwarmCLI::ExecutionError => e # CLI-specific errors (e.g., missing prompt) handle_error(e, formatter: create_formatter) exit(1) rescue Interrupt # User cancelled (Ctrl+C) $stderr.puts "\n\nExecution cancelled by user" exit(130) rescue StandardError => e # Unexpected errors handle_error(e, formatter: create_formatter) exit(1) end |