Class: Wordmove::CLI

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

Instance Method Summary collapse

Instance Method Details

#__print_versionObject



6
7
8
# File 'lib/wordmove/cli.rb', line 6

def __print_version
  puts Wordmove::VERSION
end

#doctorObject



16
17
18
# File 'lib/wordmove/cli.rb', line 16

def doctor
  Wordmove::Doctor.start
end

#initObject



11
12
13
# File 'lib/wordmove/cli.rb', line 11

def init
  Wordmove::Generators::Movefile.start
end

#listObject



64
65
66
67
68
69
70
71
72
# File 'lib/wordmove/cli.rb', line 64

def list
  Wordmove::EnvironmentsList.print(options)
rescue Wordmove::MovefileNotFound => e
  logger.error(e.message)
  exit 1
rescue Psych::SyntaxError => e
  logger.error("Your movefile is not parsable due to a syntax error: #{e.message}")
  exit 1
end

#pullObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/wordmove/cli.rb', line 78

def pull
  ensure_wordpress_options_presence!(options)
  begin
    deployer = Wordmove::Deployer::Base.deployer_for(options.deep_symbolize_keys)
  rescue MovefileNotFound => e
    logger.error(e.message)
    exit 1
  end

  Wordmove::Hook.run(:pull, :before, options)

  guardian = Wordmove::Guardian.new(options: options, action: :pull)

  handle_options(options) do |task|
    deployer.send("pull_#{task}") if guardian.allows(task.to_sym)
  end

  Wordmove::Hook.run(:pull, :after, options)
end

#pushObject



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/wordmove/cli.rb', line 102

def push
  ensure_wordpress_options_presence!(options)
  begin
    deployer = Wordmove::Deployer::Base.deployer_for(options.deep_symbolize_keys)
  rescue MovefileNotFound => e
    logger.error(e.message)
    exit 1
  end

  Wordmove::Hook.run(:push, :before, options)

  guardian = Wordmove::Guardian.new(options: options, action: :push)

  handle_options(options) do |task|
    deployer.send("push_#{task}") if guardian.allows(task.to_sym)
  end

  Wordmove::Hook.run(:push, :after, options)
end