about summary refs log tree commit diff
path: root/contrib
diff options
context:
space:
mode:
authorThomas Schneider <qsx@qsx.re>2018-09-26 22:57:57 +0200
committerLeah Neukirchen <leah@vuxu.org>2018-09-27 14:10:35 +0200
commitfbb797253d9369abedb3a7abf961ddccce00a0ed (patch)
tree2eaba95be2fcb65ca8976c5b23a438380aad5bbf /contrib
parent9d793b3662e7a35df30a9482d36f288c10120c59 (diff)
downloadmblaze-fbb797253d9369abedb3a7abf961ddccce00a0ed.tar.gz
mblaze-fbb797253d9369abedb3a7abf961ddccce00a0ed.tar.xz
mblaze-fbb797253d9369abedb3a7abf961ddccce00a0ed.zip
Add contrib/msearch
Closes: #138 [via git-merge-pr]
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/msearch38
-rw-r--r--contrib/msearch.170
2 files changed, 108 insertions, 0 deletions
diff --git a/contrib/msearch b/contrib/msearch
new file mode 100755
index 0000000..bab0616
--- /dev/null
+++ b/contrib/msearch
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+MBLAZE=${MBLAZE:-$HOME/.mblaze}
+engine=$(mhdr -h search-engine "$MBLAZE/profile")
+
+while getopts nm- opt; do
+    case $opt in
+	n)
+	    engine=notmuch
+	    ;;
+	m)
+	    engine=mu
+	    ;;
+	'?')
+	    printf "Usage: %s: [-n | -m] query\n" $0
+	    exit 1
+	    ;;
+	-)
+	    break
+	    ;;
+    esac
+done
+shift $(($OPTIND - 1))
+
+[ -z "$engine" ] && engine=notmuch
+
+case $engine in
+    notmuch)
+	exec notmuch search --output=files "$@"
+	;;
+    mu)
+	exec mu find --fields l "$@"
+	;;
+    *)
+	echo "Unsupported search engine: $engine"
+	exit 1
+	;;
+esac
diff --git a/contrib/msearch.1 b/contrib/msearch.1
new file mode 100644
index 0000000..67bd630
--- /dev/null
+++ b/contrib/msearch.1
@@ -0,0 +1,70 @@
+.Dd September 26, 2018
+.Dt MSEARCH 1
+.Os
+.Sh NAME
+.Nm msearch
+.Nd search messages
+.Sh SYNOPSIS
+.Nm
+.Op Fl n | Fl m
+.Op Fl -
+.Op Ar query
+.Sh DESCRIPTION
+.Nm
+searches for messages matching
+.Ar query ,
+using an external search engine, and prints file names separated by newlines.
+.Pp
+The options are as follows:
+.Bl -tag -width Ds
+.It Fl n
+Search using
+.Xr notmuch-search 1 .
+.It Fl m
+Search using
+.Xr mu-find 1 .
+.It Fl -
+Stop scanning for arguments.
+.It Ar query
+The search query, whose interpretation is up to the search engine.
+This can also contain additional arguments for them
+.El
+.Pp
+If no search engine is specified as an argument,
+.Sq Li Search-Engine\&:
+from
+.Pa "${MBLAZE:-$HOME/.mblaze}/profile"
+is used.
+Valid values for this setting are
+.Sq notmuch
+and
+.Sq mu .
+If that is unset,
+.Xr notmuch-search 1
+is used.
+.Sh ENVIRONMENT
+.Bl -tag -width Ds
+.It Ev MBLAZE
+Directory containing mblaze configuration files.
+(Default:
+.Pa $HOME/.mblaze )
+.El
+.Sh EXIT STATUS
+.Ex -std
+Note that the called programs may have their own exit values.
+.Sh SEE ALSO
+.Xr notmuch-search 1 ,
+.Xr mu-find 1 ,
+.Xr mblaze-profile 5
+.Sh AUTHORS
+.An Thomas Schneider Aq Mt qsx@chaotikum.eu
+.Sh LICENSE
+.Nm
+is in the public domain.
+.Pp
+To the extent possible under law,
+the creator of this work
+has waived all copyright and related or
+neighboring rights to this work.
+.Pp
+.Lk http://creativecommons.org/publicdomain/zero/1.0/