Class: AcquiaToolbelt::CLI::Environments

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

Constant Summary

Constants inherited from Thor

Thor::AmbiguousTaskError, Thor::DynamicTask, Thor::HELP_MAPPINGS, Thor::HiddenTask, Thor::THOR_RESERVED_WORDS, Thor::UndefinedTaskError, Thor::VERSION

Instance Attribute Summary

Attributes included from Thor::Base

#args, #options, #parent_options

Instance Method Summary collapse

Methods inherited from Thor

check_unknown_options!, check_unknown_options?, command_help, default_command, desc, #help, help, long_desc, map, method_option, method_options, package_name, printable_commands, register, stop_on_unknown_option!, stop_on_unknown_option?, subcommand, subcommands

Methods included from Thor::Base

included, #initialize, register_klass_file, shell, shell=, subclass_files, subclasses

Instance Method Details

#listObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/acquia_toolbelt/cli/environment.rb', line 10

def list
  if options[:subscription]
    subscription = options[:subscription]
  else
    subscription = AcquiaToolbelt::CLI::API.default_subscription
  end

  environment = options[:environment]

  # If the environment option is set, just fetch a single environment.
  if environment
    environments = [environment]
  else
    environments = AcquiaToolbelt::CLI::API.environments
  end

  environments.each do |env|
    env_info = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/envs/#{env}"
    ui.say
    ui.say "> Host: #{env_info['ssh_host']}"
    ui.say "> Environment: #{env_info['name']}"
    ui.say "> Current release: #{env_info['vcs_path']}"
    ui.say "> DB clusters: #{env_info['db_clusters'].join(', ')}"
    ui.say "> Default domain: #{env_info['default_domain']}"
  end
end

#live_developmentObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/acquia_toolbelt/cli/environment.rb', line 47

def live_development
  if options[:environment].nil?
    ui.say "No value provided for required options '--environment'"
    return
  end

  if options[:subscription]
    subscription = options[:subscription]
  else
    subscription = AcquiaToolbelt::CLI::API.default_subscription
  end

  action      = options[:action]
  environment = options[:environment]

  live_development_set = AcquiaToolbelt::CLI::API.request "sites/#{subscription}/envs/#{environment}/livedev/#{action}", 'POST'

  if live_development_set['id']
    ui.success "Live development has been successfully #{action}d on #{environment}."
  else
    ui.fail AcquiaToolbelt::CLI::API.display_error(live_development_set)
  end
end