Class: Themigrator::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/themigrator/cli.rb

Instance Method Summary collapse

Instance Method Details

#migrateObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/themigrator/cli.rb', line 9

def migrate
  migrator_opts = {}
  migrator_opts[:roles] = options[:roles].split(',') if options[:roles]
  migrator_opts[:log_stdout] = true unless options[:background]
  migrator = Themigrator::Migrator.new(Dir.pwd, migrator_opts)

  exit migrator.migrate! ? 0 : -1 unless options[:background]

  pid = fork do
    exit migrator.migrate! ? 0 : -1
  end
  Process.detach(pid)
  log_file = migrator.main_log_path(Dir.pwd, migrator.run_id)
  sleep 0.1
  # system("tail --pid=#{pid} --lines=+0 --follow #{log_file}")
  system("#{$PROGRAM_NAME} visualize #{migrator.run_id}")
end

#rolesObject



28
29
30
31
32
# File 'lib/themigrator/cli.rb', line 28

def roles
  migration = Themigrator::Migration.new(Dir.pwd)
  migration.analyze_project!
  puts migration.roles.join("\n")
end

#visualize(run_id) ⇒ Object



35
36
37
38
39
# File 'lib/themigrator/cli.rb', line 35

def visualize(run_id)
  mp = Themigrator::MigrationProgress.new(Dir.pwd, run_id)
  ui = Themigrator::UI.new(mp)
  ui.start
end