aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-10-02 16:28:14 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2012-10-02 16:28:14 +0300
commitea77a73d4119feb0481e74bfa2754ebd2100bed9 (patch)
treed5609fc4d72222d10a10e7dff758843f32732365
parent4e3ebe248cef60d084713c34594f7103f15a4035 (diff)
downloadeclat-ea77a73d4119feb0481e74bfa2754ebd2100bed9.tar.gz
eclat-ea77a73d4119feb0481e74bfa2754ebd2100bed9.tar.bz2
Add command completion routine for bash. Install formats to pkgdatadir
* README: Update. * configure.ac: Remove --with-format-dir. Use --pkgdatadir instead. * etc/Makefile.am: Add new file. * etc/compl.sh: New file.
-rw-r--r--README32
-rw-r--r--configure.ac14
-rw-r--r--etc/Makefile.am17
-rw-r--r--etc/compl.sh82
4 files changed, 113 insertions, 32 deletions
diff --git a/README b/README
index 3dd8201..a05e249 100644
--- a/README
+++ b/README
@@ -12,7 +12,7 @@ and has a tiny memory footprint.
* Documentation
-Several man pages are ready. Most is to be written yet.
+Several man pages are ready. Most are to be written yet.
* Building
@@ -21,18 +21,40 @@ The following libraries are needed for Eclat:
* Curl, available from <http://curl.haxx.se>.
* Expat, avaliable from <http://www.libexpat.org>.
-To compile, run the usual triplet:
+To compile, run the usual encantation:
./configure
make
make install
-For information about the configure script and its options, refer to
-file INSTALL included in the distribution.
+For information about the configure script and its generic options, refer to
+the file INSTALL included in the distribution.
+
+The following option is specific to this package:
+
+ --enable-split-format
+
+ Create a separate format file for each particular command. By default
+ the installation procedure builds a single file, which contains
+ instructions for each command supported by eclat. Use this option if
+ you wish to use separate files instead.
+
+** Shell completion
+
+To facilitate the use of the tool, the package includes a Bash script
+that implements completion for Eclat commands. The script is named
+compl.sh and is installed in pkgdatadir. To use it, source compl.sh
+from your profile or bash startup file (either per-user or system-wide one,
+at your option). For example, if the package is configured with /usr
+as its prefix, add the following line
+
+ . /usr/share/eclat/compl.sh
+
+Once done, you can use TAB to complete a partially typed command name.
* Bug reporting.
-Send bug reports to <gray+eclat@gnu.org.ua>.
+Send bug reports to <bug-eclat@gnu.org.ua>.
* Copyright information:
diff --git a/configure.ac b/configure.ac
index ec0d3f8..e878bca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,28 +64,14 @@ AC_CHECK_LIB([expat], [XML_Parse],[],
GRECS_SETUP([grecs],[tests getopt git2chg])
#
-AC_SUBST(FORMATDIR)
AC_ARG_ENABLE([split-format],
[AC_HELP_STRING([--enable-split-format],
[build split format files])],
[split_fmt=$enableval],
[split_fmt=no])
-if test $split_fmt = yes; then
- FORMATDIR="\$(sysconfdir)/\$(PACKAGE)"
-else
- FORMATDIR="\$(sysconfdir)"
-fi
AM_CONDITIONAL([SPLIT_FORMATS],[test $split_fmt = yes])
-AC_ARG_WITH([format-dir],
- [AC_HELP_STRING([--format-dir=DIR],
- [install format files to that directory])],
- [case $withval in
- /*) FORMATDIR=$withval;;
- *) FORMATDIR='$(prefix)/'$withval
- esac])
-
# Initialize the test suite.
AC_CONFIG_TESTDIR(tests)
AC_CONFIG_FILES([tests/Makefile tests/atlocal])
diff --git a/etc/Makefile.am b/etc/Makefile.am
index 6ef5e1a..a42deb2 100644
--- a/etc/Makefile.am
+++ b/etc/Makefile.am
@@ -37,11 +37,9 @@ if SPLIT_FORMATS
SUFFIXES += .forlan .fln
.fln.forlan:
$(AM_V_GEN)$(abs_builddir)/flncat $< default.fln > $@
-formatdir = @FORMATDIR@
FORMATFILES = $(FLNFILES:.fln=.forlan)
FORMATNAME = $${command}
else
-formatdir = @FORMATDIR@
FORMATFILES = eclat.forlan
eclat.forlan: $(FLNFILES) default.fln
$(AM_V_GEN)(cd $(srcdir); $(abs_builddir)/flncat $(FLNFILES) default.fln) > eclat.forlan
@@ -52,21 +50,14 @@ noinst_SCRIPTS=eclat.conf $(FORMATFILES)
CLEANFILES=eclat.conf $(FORMATFILES)
.cfin.conf:
- $(AM_V_GEN)sed 's^FORMATDIR^$(formatdir)^;s^FORMATNAME^$(FORMATNAME)^' $< > $@
+ $(AM_V_GEN)sed 's^FORMATDIR^$(pkgdatadir)^;s^FORMATNAME^$(FORMATNAME)^' $< > $@
-install-formats: $(FORMATFILES)
- ${INSTALL} -d $(DESTDIR)$(formatdir); \
- for file in $(FORMATFILES); do \
- ${INSTALL} -m 644 $$file $(DESTDIR)$(formatdir)/$$file; \
- done
+pkgdata_DATA = $(FORMATFILES)
+dist_pkgdata_DATA = compl.sh
install-data-local:
@test -z "$(DESTDIR)$(sysconfdir)" || $(mkdir_p) "$(DESTDIR)$(sysconfdir)"
@if [ -r $(DESTDIR)$(sysconfdir)/eclat.conf ]; then :; \
- else ${INSTALL} -m 644 $(top_srcdir)/etc/eclat.conf \
+ else ${INSTALL} -m 644 $(top_builddir)/etc/eclat.conf \
$(DESTDIR)$(sysconfdir)/eclat.conf; \
- ${INSTALL} -d $(DESTDIR)$(formatdir); \
- for file in $(FORMATFILES); do \
- ${INSTALL} -m 644 $$file $(DESTDIR)$(formatdir)/$$file; \
- done; \
fi
diff --git a/etc/compl.sh b/etc/compl.sh
new file mode 100644
index 0000000..d56f1a3
--- /dev/null
+++ b/etc/compl.sh
@@ -0,0 +1,82 @@
+#! /bin/bash
+# Bash completion setup for Eclat commands.
+# Copyright (C) 2012 Sergey Poznyakoff
+#
+# Eclat is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# Eclat is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Eclat. If not, see <http://www.gnu.org/licenses/>.
+
+comp_eclat() {
+ # Obtain a list of command line options. Each option occupies
+ # a single line and is followed by an equals sign if it takes
+ # an argument.
+ local optlist=$(eclat --usage|sed '1s/^[^[]*//' |
+ tr -d '\n' |
+ tr -s ' ' |
+ sed 's/\] \[/:/g;' |
+ tr -d '[]' |
+ awk -F: '
+ function optproc(s, i,n,a) {
+ if (match(s, /^-[a-zA-Z][a-zA-Z]/)) {
+ n = split(s, a, "");
+ for (i = 2; i <= n; i++)
+ print "-" a[i];
+ } else if (match(s, /^-[a-zA-Z] ./))
+ print substr(s,1,2) "=";
+ else {
+ if (match(s, /=/)) {
+ opt="="
+ sub(/=.*/,"",s)
+ } else
+ opt=""
+ n = split(s, a, " ");
+ for (i = 1; i <= n; i++) {
+ sub(/,$/,"",a[i])
+ print a[i] opt
+ }
+ }
+ }
+ { for (i = 1; i < NF; i++) optproc($i) }')
+
+ # Bail out if we're sitting on a word starting with a dash, i.e.
+ # an option. Otherwise, make sure no command appears in the command
+ # line to the left of the current word. If not, we're trying to
+ # complete a command, so proceed safely.
+ COMPREPLY=()
+ local opt arg=${COMP_WORDS[$COMP_CWORD]}
+ case $arg in
+ -*) return
+ esac
+ for i in $(seq $(($COMP_CWORD - 1)) -1 1)
+ do
+ opt=${COMP_WORDS[$i]}
+ case $opt in
+ -*) if test -n "$arg"; then
+ if echo "$optlist" | grep -q "^$opt.*="; then
+ test $i -eq $(($COMP_CWORD - 1)) && return
+ arg=
+ else
+ return
+ fi
+ fi
+ ;;
+ *) if test -n "$arg" && test $i -lt $(($COMP_CWORD - 1)); then
+ return
+ else
+ arg=$opt
+ fi
+ esac
+ done
+ # Finally, find matching commands.
+ COMPREPLY=( $(eclat --match-commands ${COMP_WORDS[$COMP_CWORD]}) )
+}
+complete -F comp_eclat eclat

Return to:

Send suggestions and report system problems to the System administrator.