Class: PEBuild::Command::Download

Inherits:
Object
  • Object
show all
Defined in:
lib/pe_build/command/download.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



5
6
7
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
# File 'lib/pe_build/command/download.rb', line 5

def execute

  options = {}

  parser = OptionParser.new do |o|
    o.banner = "Usage: vagrant pe-build download --version <version> --dir <dir>"
    o.separator ''

    o.on('-v', '--version=val', String, "The version of PE to fetch") do |val|
      options[:version] = val
    end

    o.on('-d', '--dir=val', String, 'The URL basedir containing the file') do |val|
      options[:dir] = val
    end
  end

  argv = parse_options(parser)
  filename = argv.last

  unless options[:version]
    raise Vagrant::Errors::CLIInvalidUsage, :help => parser.help.chomp
  end

  uri = URI.parse(options[:dir])

  archive = PEBuild::Archive.new(filename, @env)
  archive.version = options[:version]
  archive.fetch(options[:dir])
end