Sha256: 535826d33cf925712ddd9339d9e7bc52836007f33852a9c7e7afec19ee33dc4a

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

module Landrush
  class Command < Vagrant.plugin('2', :command)
    DAEMON_COMMANDS = %w(start stop restart status)

    def execute
      ARGV.shift # flush landrush from ARGV, RExec wants to use it for daemon commands

      command = ARGV.first
      if DAEMON_COMMANDS.include?(command)
        Server.daemonize
      elsif command == 'dependentvms'
        if DependentVMs.any?
          @env.ui.info(DependentVMs.list.map { |dvm| " - #{dvm}" }.join("\n"))
        else
          @env.ui.info("No dependent VMs")
        end
      elsif command == 'install'
        ResolverConfig.ensure_config_exists
      else
        boom("'#{command}' is not a command")
      end

      0 # happy exit code
    end

    def boom(msg)
      raise Vagrant::Errors::CLIInvalidOptions, :help => usage(msg)
    end

    def usage(msg); <<-EOS.gsub(/^      /, '')
      ERROR: #{msg}

      vagrant landrush <command>

      commands:
        {start|stop|restart|status}
          control the landrush server daemon
        dependentvms
          list vms currently dependent on the landrush server
        install
          install resolver config for host visbility (requires sudo)
      EOS
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
landrush-0.8.0 lib/landrush/command.rb
landrush-0.7.1 lib/landrush/command.rb
landrush-0.7.0 lib/landrush/command.rb
landrush-0.6.0 lib/landrush/command.rb
landrush-0.5.0 lib/landrush/command.rb
landrush-0.4.1 lib/landrush/command.rb