diff options
-rwxr-xr-x | src/librefetch/librefetch | 64 |
1 files changed, 27 insertions, 37 deletions
diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index e9e45fd..19942ef 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -27,51 +27,46 @@ 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|P|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." + prose "The default mode is to create OUTPUT_FILE, first by trying + download 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." + prose "If OUTPUT_FILE isn't specified, it defaults to the non-directory + 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." + prose "In download mode, the glob '*://' is stripped from the beginning + of SOURCE_URL, and the resulting path is attempted to be + downloaded 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>." + prose "In create mode, it looks at a build script, and uses that to + create the source tarball. SOURCE_URL is ignored, except that it + is used to set the default value of OUTPUT_FILE." echo - print "The default build script is 'PKGBUILD', or 'SRCBUILD' if it exists." + prose "The default build script is 'PKGBUILD', or 'SRCBUILD' if it + exists." echo - print "Unrecognized options are passed straight to makepkg." + prose "Unrecognized options are passed straight to makepkg." + echo + prose "%s does NOT support getopt-style flag combining. You must use + '-a -b', not '-ab'." "$cmd" echo print "Example usage:" print ' $ %s libre://mypackage-1.0.tar.gz' "$cmd" echo print "Options:" print " Settings:" - print " -C Force create mode (don't download)" - print " -D Force download mode (don't create)" - print " -p <file> Use an alternate build script (instead of 'PKGBUILD')" - print " If an SRCBUILD exists in the same directory, it is used" - print " instead" + flag "-C" "Force create mode (don't download)" + flag "-D" "Force download mode (don't create)" + flag "-p <$(_ FILE)>" "Use an alternate build script (instead of + 'PKGBUILD') If an SRCBUILD exists in the same + directory, it is used instead" print " Alternate modes:" - print " -g, --geninteg Generage integrity checks for source files" - print " -P, --print Print the effective build script (SRCBUILD)" - print " -V, --version Show version information" - print " -h, --help Show this message" -} - -version() { - print "librefetch (libretools) beta 4" - echo - print "Copyright (C) 2013 Luke Shumaksr <lukeshu@sbcglobal.net>" - print "This is free software; see the source for copying conditions." - print "There is NO WARRANTY, to the extent permitted by law." + flag "-g, --geninteg" "Generage integrity checks for source files" + flag "-P, --print" "Print the effective build script (SRCBUILD)" + flag "-h, --help" "Show this message" } main() { @@ -81,12 +76,8 @@ main() { mode=download-create parse_options "$@" - # Mode: version, help ################################################## + # Mode: help ########################################################### - if [[ $mode =~ version ]]; then - version - return 0 - fi if [[ $mode =~ help ]]; then usage return 0 @@ -179,7 +170,7 @@ main() { # sets the variables BUILDFILE, makepkg_opts, extra_opts, mode parse_options() { # Detect makepkg options that take a second argument - local makepkg_orig="$(which "${MAKEPKG:-makepkg}")" + local makepkg_orig="$(which makepkg)" local makepkg_opt2long=($("${makepkg_orig}" -h | sed -rn 's/\s*(--\S*) <.*/\1/p')) local makepkg_opt2short=($("${makepkg_orig}" -h | sed -rn 's/\s*(-.) <.*/\1/p')) @@ -204,7 +195,6 @@ parse_options() { -g|--geninteg) mode=checksums;; -P|--print) mode=print;; -p) BUILDFILE="$(readlink -m -- "$opt")";; - -V|--version) mode=version;; -h|--help) mode=help;; -*) makepkg_opts+=("$arg") |