Module: Engineyard::Local::Command

Defined in:
lib/engineyard-local/command.rb,
lib/engineyard-local/command.rb,
lib/engineyard-local/command/up.rb,
lib/engineyard-local/command/base.rb,
lib/engineyard-local/command/exec.rb,
lib/engineyard-local/command/help.rb,
lib/engineyard-local/command/list.rb,
lib/engineyard-local/command/stop.rb,
lib/engineyard-local/command/group.rb,
lib/engineyard-local/command/rails.rb,
lib/engineyard-local/command/start.rb,
lib/engineyard-local/command/status.rb,
lib/engineyard-local/command/update.rb,
lib/engineyard-local/command/helpers.rb,
lib/engineyard-local/command/terminate.rb,
lib/engineyard-local/command/vagrant_action.rb

Defined Under Namespace

Modules: Helpers Classes: Base, Exec, Group, Help, List, Rails, Start, Status, Stop, Terminate, Up, Update, VagrantAction

Constant Summary collapse

COMMANDS_WITH_NO_COOKBOOK_CHECK =
[Engineyard::Local::Command::Terminate, Engineyard::Local::Command::Status, Engineyard::Local::Command::Update, Vagrant::Command::Suspend, Vagrant::Command::Halt]

Class Method Summary collapse

Class Method Details

.allObject



5
6
7
# File 'lib/engineyard-local/command.rb', line 5

def self.all
  Engineyard::Local.locales[:commands].keys.map { |cmd| cmd.to_s }
end

.dispatch(args) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/engineyard-local/command.rb', line 13

def self.dispatch(args)
  Group.env = env = vagrant_env(args)

  # if the flags need to be sent through on the command, avoid Thor
  # otherwise start up Thor command line handling. Otherwise notify wrapper
  # that nothing was dispatched.
  if args.include?("-v") || args.include?("--version")
    env.ui.info Engineyard::Local::VERSION, :prefix => false
  elsif passthrough.include?(args.first)
    cmd = Group.new(args, [], {})
    cmd.send(args.first.to_sym, *args[1, args.length])
  elsif all.include?(args.first) || args.length == 0
    Group.start(args)
  else
    vagrant_env(args).cli(args)
  end
rescue Vagrant::Errors::VagrantError => e
  # TODO move to Vagrant Environment ui error
  env.ui.error e.message if e.message
  exit e.status_code if e.respond_to?(:status_code)
  exit 999
end

.passthroughObject



9
10
11
# File 'lib/engineyard-local/command.rb', line 9

def self.passthrough
  Engineyard::Local.config[:commands][:passthrough]
end

.vagrant_env(args) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/engineyard-local/command.rb', line 36

def self.vagrant_env(args)
  opts = {}

  # setup the vagrant env properly for the commands to run
  if args.include?("--no-color") || !$stdout.tty? || !Vagrant::Util::Platform.terminal_supports_colors?
    # Delete the argument from the list so that it doesn't cause any
    # invalid arguments down the road.
    args.delete("--no-color")
    opts[:ui_class] = UI::Basic
  else
    opts[:ui_class] = UI::Colored
  end

  new_env = Vagrant::Environment.new(opts)
  new_env.load!
  new_env
end