Class: SwarmCLI::Commands::Migrate

Inherits:
Object
  • Object
show all
Defined in:
lib/swarm_cli/commands/migrate.rb

Overview

Migrate command converts Claude Swarm v1 configurations to SwarmSDK v2 format.

Usage:

swarm migrate old-config.yml
swarm migrate old-config.yml --output new-config.yml

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Migrate

Returns a new instance of Migrate.



14
15
16
# File 'lib/swarm_cli/commands/migrate.rb', line 14

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



12
13
14
# File 'lib/swarm_cli/commands/migrate.rb', line 12

def options
  @options
end

Instance Method Details

#executeObject



18
19
20
21
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
# File 'lib/swarm_cli/commands/migrate.rb', line 18

def execute
  # Validate options
  options.validate!

  # Create migrator
  migrator = Migrator.new(options.input_file)

  # Perform migration
  migrated_yaml = migrator.migrate

  # Write to output file or stdout
  if options.output
    File.write(options.output, migrated_yaml)
    $stderr.puts "✓ Migration complete! Converted configuration saved to: #{options.output}"
  else
    puts migrated_yaml
  end

  exit(0)
rescue SwarmCLI::ExecutionError => e
  handle_error(e)
  exit(1)
rescue Interrupt
  $stderr.puts "\n\nMigration cancelled by user"
  exit(130)
rescue StandardError => e
  handle_error(e)
  exit(1)
end