diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/librefetch/librefetch | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 368bfb4..3d37123 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -27,16 +27,30 @@ trap cleanup EXIT cmd=${0##*/} usage() { - print "Usage: %s [options] <source-url> <output-file>" "$cmd" + print "Usage: %s [options] <source-url> [<output-file>]" "$cmd" print "Usage: %s -[g|V|h]" "$cmd" print "Downloads or creates a liberated source tarball." echo + print "The default mode is to create <output-file>, first by trying download" + print "mode, then create mode." + echo + print "If <output-file> isn't specified, it defaults to the non-directory" + print "part of <source-url>, in the current directory." + echo + print "In download mode, the glob '*://' is stripped from the beginning of" + print "<source-url>, and the resulting path is attempted to be downloaded" + print "from the configured mirror." + echo + print "In create mode, it looks at a build script, and uses that to create" + print "the source tarball. <source-url> is ignored, except that it is used" + print "to set the default value of <output-file>." + echo print "The default build script is 'PKGBUILD', or 'SRCBUILD' if it exists." echo print "Unrecognized options are passed straight to makepkg." echo print "Example usage:" - print ' $ %s libre://mypackage-1.0.tar.gz $SRCDEST/mypackage-1.0.tar.gz.part' "$cmd" + print ' $ %s libre://mypackage-1.0.tar.gz' "$cmd" echo print "Options:" print " Settings:" @@ -106,13 +120,21 @@ main() { ######################################################################## - if [[ ${#extra_opts[@]} != 2 ]]; then - print "%s: %d non-flag arguments found, expected 2: %s" "$cmd" ${#extra_opts[@]} >> /dev/stderr - usage >> /dev/stderr - return 1 - fi - local src="${extra_opts[0]#*://}" - local dst="$(readlink -m "${extra_opts[1]}")" + local src dst + case ${#extra_opts[@]} in + 1) + src="${extra_opts[0]#*://}" + dst="$(readlink -m "${src##*/}")" + ;; + 2) + src="${extra_opts[0]#*://}" + dst="$(readlink -m "${extra_opts[1]}")" + ;; + *) + print "%s: %d non-flag arguments found, expected 1 or 2: %s" "$cmd" ${#extra_opts[@]} >> /dev/stderr + usage >> /dev/stderr + return 1 + esac # Mode: download ####################################################### |