Module: Bebox::EnvironmentCommands

Defined in:
lib/bebox/commands/environment_commands.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



5
6
7
# File 'lib/bebox/commands/environment_commands.rb', line 5

def self.extended(base)
  base.load_commands
end

Instance Method Details

#environment_list_command(environment_command) ⇒ Object

Environment list command



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/bebox/commands/environment_commands.rb', line 31

def environment_list_command(environment_command)
  environment_command.desc 'List the remote environments in the project'
  environment_command.command :list do |environment_list_command|
    environment_list_command.action do |global_options,options,args|
      environments = Bebox::Environment.list(project_root)
      title 'Current environments:'
      environments.map{|environment| msg(environment)}
      warn('There are not environments yet. You can create a new one with: \'bebox environment new\' command.') if environments.empty?
    end
  end
end

#generate_environment_command(environment_command, command, send_command, description) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/bebox/commands/environment_commands.rb', line 19

def generate_environment_command(environment_command, command, send_command, description)
  environment_command.desc description
  environment_command.arg_name "[environment]"
  environment_command.command command do |generated_command|
    generated_command.action do |global_options,options,args|
      help_now!(error('You did not supply an environment')) if args.count == 0
      Bebox::EnvironmentWizard.new.send(send_command, project_root, args.first)
    end
  end
end

#load_commandsObject



9
10
11
12
13
14
15
16
17
# File 'lib/bebox/commands/environment_commands.rb', line 9

def load_commands
  # Environment management phase commands
  desc 'Manage environments for the project. The \'vagrant\', \'production\' and \'staging\' environments are present by default.'
  command :environment do |environment_command|
    environment_list_command(environment_command)
    generate_environment_command(environment_command, :new, :create_new_environment, 'Add a remote environment to the project')
    generate_environment_command(environment_command, :remove, :remove_environment, 'Remove a remote environment in the project')
  end
end