lib/pe_build/command/copy.rb in vagrant-pe_build-0.2.0 vs lib/pe_build/command/copy.rb in vagrant-pe_build-0.3.0
- old
+ new
@@ -1,38 +1,37 @@
-require 'vagrant'
-require 'optparse'
require 'pe_build/archive'
-module PEBuild
-class Command
-class Copy < Vagrant.plugin(2, :command)
+class PEBuild::Command::Copy < Vagrant.plugin(2, :command)
+ def initialize(argv, env)
+ super
+ @options = {}
+ end
+
def execute
+ argv = parse_options(parser)
- options = {}
+ filename = File.basename(argv.last)
+ src_dir = File.dirname(argv.last)
- parser = OptionParser.new do |o|
+ archive = PEBuild::Archive.new(filename, @env)
+ archive.version = @options[:version]
+
+ uri = URI.parse src_dir
+ archive.fetch(uri)
+
+ @env.ui.info "pe-build: #{archive} has been added and is ready for use!", :prefix => true
+ end
+
+ private
+
+ def parser
+ OptionParser.new do |o|
o.banner = "Usage: vagrant pe-build copy path/to/installer.tar.gz"
o.separator ''
o.on('-v', '--version=val', String, "The version of PE to fetch") do |val|
options[:version] = val
end
end
-
- argv = parse_options(parser)
- fpath = argv.last
-
- basename = File.basename(fpath)
- dirname = File.dirname(fpath)
-
- #unless options[:version]
- # raise Vagrant::Errors::CLIInvalidUsage, :help => parser.help.chomp
- #end
-
- archive = PEBuild::Archive.new(fpath, @env)
- archive.version = options[:version]
- archive.copy_from(dirname)
end
-end
-end
end