summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouie <lshprung@yahoo.com>2021-02-21 20:18:24 -0800
committerlouie <lshprung@yahoo.com>2021-02-21 20:18:24 -0800
commit2ef8fc717cb2954461be5a8274f962ad3a98d0a0 (patch)
treeb00cf5f6f58a315a4deb4a07cba3a665880e01ef
parent4a51ba24c1ef4bd2612a44b095a27b12b862abb2 (diff)
Added help list
-rw-r--r--README.md2
-rwxr-xr-xpkg-screenshot.sh34
2 files changed, 26 insertions, 10 deletions
diff --git a/README.md b/README.md
index 88b4956..7aec104 100644
--- a/README.md
+++ b/README.md
@@ -14,4 +14,6 @@ pkg-screenshot.sh [options] package
### Options
+**-h, --help** - Print a help list
+
**--no-download** - Open the image URL instead of saving an image file in /tmp/
diff --git a/pkg-screenshot.sh b/pkg-screenshot.sh
index 3438606..6095898 100755
--- a/pkg-screenshot.sh
+++ b/pkg-screenshot.sh
@@ -2,15 +2,29 @@
if [ -z $1 ]; then
echo "Error: Missing package name"
- echo "Usage: pkg-screenshot.sh package"
+ echo "Usage: pkg-screenshot.sh [options] package"
fi
-if [ $1 != "--no-download" ]; then
- URL=`wget -qO- https://screenshots.debian.net/json/package/$1 | jq '.screenshots[0].large_image_url' | tr -d \"`
- EXTENSION=`echo $URL | rev | cut -d . -f 1 | rev`
- wget -qO /tmp/pkg-screenshot.$EXTENSION $URL
- xdg-open /tmp/pkg-screenshot.$EXTENSION
-else
- URL=`wget -qO- https://screenshots.debian.net/json/package/$2 | jq '.screenshots[0].large_image_url' | tr -d \"`
- xdg-open $URL
-fi
+case $1 in
+#if [[ $1 == "-h" || $1 == "--help" ]]; then
+ -h|--help)
+ echo "Usage: pkg-screenshot.sh [options] package"
+ echo ""
+ echo " -h, --help give this help list"
+ echo " --no-download Open the image URL instead of saving an image file in /tmp/"
+ ;;
+
+#elif [ $1 != "--no-download" ]; then
+ --no-download)
+ URL=`wget -qO- https://screenshots.debian.net/json/package/$2 | jq '.screenshots[0].large_image_url' | tr -d \"`
+ xdg-open $URL
+ ;;
+
+#else
+ *)
+ URL=`wget -qO- https://screenshots.debian.net/json/package/$1 | jq '.screenshots[0].large_image_url' | tr -d \"`
+ EXTENSION=`echo $URL | rev | cut -d . -f 1 | rev`
+ wget -qO /tmp/pkg-screenshot.$EXTENSION $URL
+ xdg-open /tmp/pkg-screenshot.$EXTENSION
+ ;;
+esac