[Surfraw-devel] [PATCH] Added new elvis: dockerhub

Dmitry Bogatov KAction at gnu.org
Wed Oct 10 02:12:56 BST 2018


---
 ChangeLog        |  4 ++++
 README           |  1 +
 elvi/Makefile.am |  1 +
 elvi/dockerhub   | 60 ++++++++++++++++++++++++++++++++++++++++++++++++
 links.IN         |  1 +
 5 files changed, 67 insertions(+)
 create mode 100755 elvi/dockerhub

diff --git a/ChangeLog b/ChangeLog
index 3ec3e5e..794c030 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2018-10-09  Dmitry Bogatov <KAction at gnu.org>
+
+	* new elvi: dockerhub
+
 2018-01-13  Jason Ryan <jasonwryan at gmail.com>
 	* Bump version to 2.3.0
 	* Select Perl version at buildtime (Mark Meyer)
diff --git a/README b/README
index 6ba4151..07c73dc 100644
--- a/README
+++ b/README
@@ -211,6 +211,7 @@ debvcsbrowse    -- Browse the VCS repository for a Debian package
 debwiki         -- Search the Debian Wikis (wiki.debian.org & women.debian.org/wiki)
 deja            -- Search usenet using Google Groups (groups.google.com)
 discogs         -- Search the Discogs database of music information (www.discogs.com)
+dockerhub       -- Search for Docker images (https://hub.docker.com)
 duckduckgo      -- Securely search the web using duckduckgo (www.duckduckgo.com)
 ebay            -- Search the Ebay auction site
 etym            -- Look up word origins at www.etymonline.com
diff --git a/elvi/Makefile.am b/elvi/Makefile.am
index 9c41f00..a0a9bda 100644
--- a/elvi/Makefile.am
+++ b/elvi/Makefile.am
@@ -42,6 +42,7 @@ dist_elvi_SCRIPTS	= \
 		  debwiki \
 		  deja \
 		  discogs \
+		  dockerhub \
 		  duckduckgo \
 		  ebay \
 		  etym \
diff --git a/elvi/dockerhub b/elvi/dockerhub
new file mode 100755
index 0000000..4b8838f
--- /dev/null
+++ b/elvi/dockerhub
@@ -0,0 +1,60 @@
+#!/bin/sh
+# $Id$
+# elvis: dockerhub -- Search for Docker images (https://hub.docker.com)
+. surfraw || exit 1
+
+w3_config_hook () {
+    defyn SURFRAW_dockerhub_automatic 0
+    defyn SURFRAW_dockerhub_official  0
+    def   SURFRAW_dockerhub_pulls     0
+    def   SURFRAW_dockerhub_stars     0
+}
+
+w3_usage_hook () {
+    cat <<EOF
+Usage: $w3_argv0 [options] [search words]
+Description:
+  Surfraw search the Docker images.
+Local options:
+  -automatic                    Search only for automatically built images
+                                Default: $SURFRAW_dockerhub_automatic
+                                Environment: SURFRAW_dockerhub_automatic
+  -official                     Search only for official images
+                                Default: $SURFRAW_dockerhub_official
+  -pulls                        Search only for images with no less than
+                                given number of pulls
+                                Default: $SURFRAW_dockerhub_pulls
+                                Environment: SURFRAW_dockerhub_pulls
+  -stars                        Search only for images with no less than
+                                given number of stars
+                                Default: $SURFRAW_dockerhub_stars
+                                Environment: SURFRAW_dockerhub_stars
+EOF
+    w3_global_usage
+}
+
+w3_parse_option_hook () {
+    opt="$1"
+    optarg="$2"
+    case "$opt" in
+        (-a|-auto*)     setoptyn SURFRAW_dockerhub_automatic 1         ;;
+        (-f|-off*)      setoptyn SURFRAW_dockerhub_official  1         ;;
+        (-s=*|-stars=*) setopt   SURFRAW_dockerhub_stars     "$optarg" ;;
+        (-p=*|-pulls=*) setopt   SURFRAW_dockerhub_pulls     "$optarg" ;;
+        (*) return 1 ;;
+    esac
+    return 0
+}
+
+w3_config
+w3_parse_args "$@"
+
+escaped_args=$(w3_url_of_arg $w3_args)
+url='https://hub.docker.com/search/'
+url="${url}?isAutomated=${SURFRAW_dockerhub_automatic}"
+url="${url}&isOfficial=${SURFRAW_dockerhub_official}"
+url="${url}&pullCount=${SURFRAW_dockerhub_pulls}"
+url="${url}&starCount=${SURFRAW_dockerhub_stars}"
+url="${url}&q=${escaped_args}"
+
+w3_browse_url "${url}"
diff --git a/links.IN b/links.IN
index dc12a4c..18c4911 100644
--- a/links.IN
+++ b/links.IN
@@ -38,6 +38,7 @@ elvi.1sr.gz @mandir@/man1/debwiki.1sr.gz
 elvi.1sr.gz @mandir@/man1/deja.1sr.gz
 elvi.1sr.gz @mandir@/man1/discogs.1sr.gz
 elvi.1sr.gz @mandir@/man1/duckduckgo.1sr.gz
+elvi.1sr.gz @mandir@/man1/dockerhub.1sr.gz
 elvi.1sr.gz @mandir@/man1/ebay.1sr.gz
 elvi.1sr.gz @mandir@/man1/etym.1sr.gz
 elvi.1sr.gz @mandir@/man1/excite.1sr.gz



More information about the Surfraw-devel mailing list