#!/bin/bash
# wget - wget support

set -e

net_tool_wget_config_init() {
	lib_setting_vars wget_mirror
	lib_setting_vars wget_continue
	lib_setting_vars wget_directories
	lib_setting_vars wget_prereqs
	lib_setting_vars wget_munge_exts
	lib_setting_vars wget_convert_links
	lib_setting_vars wget_host_dirs
	lib_setting_vars --null wget_prefix
	lib_setting_vars --null wget_output
	lib_setting_vars --null wget_wait_secs

	wget_directories=true
	wget_mirror=false
	wget_continue=false
	wget_prereqs=false
	wget_munge_exts=false
	wget_convert_links=false
	wget_host_dirs=false
}

run_wget() {
	min_args 1 "$@"
	local -a opts
	$verbose || opts+=( --quiet )
	! $debug || opts+=( --verbose )
	! $wget_mirror || opts+=( --mirror )
	! $wget_continue || opts+=( --continue )
	$wget_directories || opts+=( --no-directories )
	! $wget_prereq || opts+=( --page-requisites )
	! $wget_munge_exts || opts+=( --adjust-extension )
	! $wget_convert_links || opts+=( --convert-links )
	$wget_host_dirs || opts+=( --no-host-directories )
	[ -z "$wget_cut_dirs" ] || opts+=( --cut-dirs "$wget_cut_dirs" )
	[ -z "$wget_prefix" ] || opts+=( --directory-prefix "$wget_prefix" )
	[ -z "$wget_wait_secs" ] || opts+=( --wait "$wget_wait_secs" )
	[ -z "$wget_output" ] || opts+=( --output-document "$wget_output" )

	opts+=( --show-progress --progress=bar:noscroll )
	run wget "${opts[@]}" "$@"
}

wget_mirror() {
	min_args 1 "$@"
	local wget_mirror=true
	local wget_prereqs=true
	local wget_munge_exts=true
	local wget_convert_links=true
	local wget_host_dirs=true
	local wget_prefix="/"
	run_wget "$@"
}

wget_files() {
	min_args 1 "$@"
	local wget_continue=true
	local wget_directories=false
	run_wget "$@"
}

View the Script Reference Index


Generated on Tue Apr 25 21:21:09 PDT 2017 by mcsh i7 v0.18.0.