diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-08-07 23:46:19 -0600 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-08-07 23:46:19 -0600 |
commit | 14a150b73b66288dfdd67a275d88a0367c122210 (patch) | |
tree | 0d5374c9dbbb519edfae3891a12424af220c0fb2 /src/librefetch/librefetch | |
parent | 45ed1620d3aaad1978782a437211fc51b383eec6 (diff) |
librefetch: add a `print` mode
Diffstat (limited to 'src/librefetch/librefetch')
-rwxr-xr-x | src/librefetch/librefetch | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 168d30e..3a5aef2 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -28,7 +28,7 @@ trap cleanup EXIT cmd=${0##*/} usage() { print "Usage: %s [options] <source-url> [<output-file>]" "$cmd" - print "Usage: %s -[g|V|h]" "$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" @@ -61,6 +61,7 @@ usage() { print " 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" } @@ -118,6 +119,18 @@ main() { return 0 fi + # Mode: print ########################################################## + + if [[ $mode =~ print ]]; then + if [[ ${#extra_opts[@]} != 0 ]]; then + print "%s: found extra non-flag arguments: %s" "$cmd" "${extra_opts[*]}" >> /dev/stderr + usage >> /dev/stderr + return 1 + fi + cat "$srcbuild" + return 0 + fi + ######################################################################## local src dst @@ -189,6 +202,7 @@ parse_options() { -C) mode=create;; -D) mode=download;; -g|--geninteg) mode=checksums;; + -P|--print) mode=print;; -p) BUILDFILE="$(readlink -m -- "$opt")";; -V|--version) mode=version;; -h|--help) mode=help;; |