downloader.rb: Add --help
option
This commit is contained in:
parent
f082605735
commit
eceb36c7b9
@ -407,26 +407,42 @@ if $0 == __FILE__
|
|||||||
|
|
||||||
case ARGV[0]
|
case ARGV[0]
|
||||||
when '-d', '--destdir'
|
when '-d', '--destdir'
|
||||||
|
## -d, --destdir DIRECTORY Download into the directory
|
||||||
destdir = ARGV[1]
|
destdir = ARGV[1]
|
||||||
ARGV.shift
|
ARGV.shift
|
||||||
when '-p', '--prefix'
|
when '-p', '--prefix'
|
||||||
# strip directory names from the name to download, and add the
|
## -p, --prefix Strip directory names from the name to download,
|
||||||
# prefix instead.
|
## and add the prefix instead.
|
||||||
prefix = ARGV[1]
|
prefix = ARGV[1]
|
||||||
ARGV.shift
|
ARGV.shift
|
||||||
when '-e', '--exist', '--non-existent-only'
|
when '-e', '--exist', '--non-existent-only'
|
||||||
|
## -e, --exist, --non-existent-only Skip already existent files.
|
||||||
since = nil
|
since = nil
|
||||||
when '-a', '--always'
|
when '-a', '--always'
|
||||||
|
## -a, --always Download all files.
|
||||||
since = false
|
since = false
|
||||||
when '-u', '--update', '--if-modified'
|
when '-u', '--update', '--if-modified'
|
||||||
|
## -u, --update, --if-modified Download newer files only.
|
||||||
since = true
|
since = true
|
||||||
when '-n', '--dryrun'
|
when '-n', '--dryrun'
|
||||||
|
## -n, --dryrun Do not download actually.
|
||||||
options[:dryrun] = true
|
options[:dryrun] = true
|
||||||
when '--cache-dir'
|
when '--cache-dir'
|
||||||
|
## --cache-dir DIRECTORY Cache downloaded files in the directory.
|
||||||
options[:cache_dir] = ARGV[1]
|
options[:cache_dir] = ARGV[1]
|
||||||
ARGV.shift
|
ARGV.shift
|
||||||
when /\A--cache-dir=(.*)/m
|
when /\A--cache-dir=(.*)/m
|
||||||
options[:cache_dir] = $1
|
options[:cache_dir] = $1
|
||||||
|
when /\A--help\z/
|
||||||
|
## --help Print this message
|
||||||
|
puts "Usage: #$0 [options] relative-url..."
|
||||||
|
File.foreach(__FILE__) do |line|
|
||||||
|
line.sub!(/^ *## /, "") or next
|
||||||
|
break if line.chomp!.empty?
|
||||||
|
opt, desc = line.split(/ {2,}/, 2)
|
||||||
|
printf " %-28s %s\n", opt, desc
|
||||||
|
end
|
||||||
|
exit
|
||||||
when /\A-/
|
when /\A-/
|
||||||
abort "#{$0}: unknown option #{ARGV[0]}"
|
abort "#{$0}: unknown option #{ARGV[0]}"
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user