Sha256: d2da00fa94a73b53b7088fc1b4c328440808b145a05121f5a5ba51c18f56ff00
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
require "down_universe/version" require_relative "./down_universe.rb" require "optparse" class Application attr_accessor :type, :user, :password, :output, :url include DownUniverse::Downloadable def run # Parsing command line arguments OptionParser.new do |opts| opts.banner = "Usage: down_universe [options] url output.It Downloads the given 'url' and saves it in 'output' file" opts.on("--user", "Sets the HTTP or FTP user.") do |user| self.user = user end opts.on("--password", "Sets the HTTP or FTP password.") do |password| self.password = password end opts.on("-t", "--type DOWNLOAD_TYPE", "Sets the download type available types are 'torrent', 'http' or 'ftp'. 'http' is the default value.") do |type| self.type = type end end.parse! # Get the output path and url from the ARGV variable self.output = ARGV.pop self.url = ARGV.pop # Set default download type to http self.type = 'http' case self.type.downcase when 'http' http_download(self.url, self.output, self.user, self.password) when 'ftp' puts "Not implemented yet." when 'torrent' puts "Not implemented yet." else puts "The 'type' option could be one of the 'http', 'ftp' or 'torrent' options." end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
down_universe-0.0.1 | lib/application.rb |