Class: VagrantPlugins::Dotvm::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-dotvm/command.rb

Constant Summary collapse

COMMANDS =
%w(init)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.synopsisObject



8
9
10
# File 'lib/vagrant-dotvm/command.rb', line 8

def self.synopsis
  'manages DotVM configuration'
end

Instance Method Details

#executeObject



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

def execute
  opts = OptionParser.new do |o|
    o.banner = sprintf 'Usage: vagrant dotvm <%s>', COMMANDS.join('|')
    o.separator ''

    o.on('-h', '--help', 'Print this help') do
      safe_puts(opts.help)
      return nil
    end
  end

  argv = parse_options(opts)
  command = argv[0]

  if !command || !COMMANDS.include?(command)
    safe_puts opts.help
    return nil
  end

  send("command_#{command}")
end