Sha256: 261f37360c5c41443e482478d7a33943a69f9c969bbd5459e3c2f32cc30c7220

Contents?: true

Size: 915 Bytes

Versions: 1

Compression:

Stored size: 915 Bytes

Contents

#!/usr/bin/env ruby

require 'trollop'

root = File.expand_path('../../', __FILE__)
lib = "#{root}/lib"
$:.unshift lib unless $:.include?(lib)

require 'dl'

opts = Trollop::options do
  version "dl #{Dl::VERSION} (c) 2011 Mark Szymanski"
  banner <<-EOS
dl is an extremely simplified version of wget/curl, written in Ruby.

Usage:

    dl [options] <url>

Where [options] are:
EOS
  opt :raw, "Don't save downloaded data to disk, simply print it to standard output."
  opt :quiet, "Don't output any download status info."
  opt :file, "Output to a specific filename, will not work in conjunction with the --raw option.", :type => :string
end

if opts[:raw] == true and opts[:file] != nil
  puts "Error: --raw and --file cannot be used in conjunction"
  exit 1
end

Dl::be_quiet = opts[:quiet]
Dl::file = opts[:file]

if ARGV[0].nil?
  puts "Error: No URL specified."
  exit 1
end

Dl::download ARGV[0], opts[:raw]

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dl-1.2.3 bin/dl