Class: Vagrant::Boxinfo::Command

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.synopsisObject



4
5
6
# File 'lib/vagrant-boxinfo/command.rb', line 4

def self.synopsis
  'The `boxinfo` command provides information about boxes based on metadata.json.'
end

Instance Method Details

#executeObject



8
9
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
36
37
# File 'lib/vagrant-boxinfo/command.rb', line 8

def execute
  options = {}

  opts = OptionParser.new do |o|
    o.banner = 'Usage: vagrant boxinfo <name or url>'
    o.separator ''
  end

  # Parse the options
  argv = parse_options(opts)
  return if !argv

  if argv.empty? || argv.length > 1
    raise Vagrant::Errors::CLIInvalidUsage,
          help: opts.help.chomp
  end

  arg = argv[0]
  url = if arg.start_with?('http://', 'https://')
          arg
        else
          (arg)
        end

  @env.ui.info("Reading url #{url}...")

  print_info(download(url))

  0
end