aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-02-04 14:51:32 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-02-04 14:51:32 +0000
commitd09a6dfe99f3be3ec6687bf8fd6611d270e793ab (patch)
tree1a5f9954d3fff90a42bbfa2aa586199830d6b5a4
parent438b270c581690c18cd966815279ad9f5abada79 (diff)
downloadpaludis-d09a6dfe99f3be3ec6687bf8fd6611d270e793ab.tar.gz
paludis-d09a6dfe99f3be3ec6687bf8fd6611d270e793ab.tar.xz
Add the start of inquisitio, a search client.
-rw-r--r--configure.ac58
-rwxr-xr-xmisc/make_sr.bash16
-rw-r--r--src/clients/inquisitio/Makefile.am89
-rw-r--r--src/clients/inquisitio/command_line.cc96
-rw-r--r--src/clients/inquisitio/command_line.hh95
-rw-r--r--src/clients/inquisitio/description_extractor.cc54
-rw-r--r--src/clients/inquisitio/description_extractor.hh39
-rw-r--r--src/clients/inquisitio/do_search.cc120
-rw-r--r--src/clients/inquisitio/do_search.hh30
-rw-r--r--src/clients/inquisitio/extractor.cc55
-rw-r--r--src/clients/inquisitio/extractor.hh64
-rwxr-xr-xsrc/clients/inquisitio/help_TEST4
-rw-r--r--src/clients/inquisitio/inquisitio.cc165
-rw-r--r--src/clients/inquisitio/man_inquisitio.cc70
-rw-r--r--src/clients/inquisitio/matcher.cc57
-rw-r--r--src/clients/inquisitio/matcher.hh66
-rw-r--r--src/clients/inquisitio/matcher.sr11
-rw-r--r--src/clients/inquisitio/name_extractor.cc34
-rw-r--r--src/clients/inquisitio/name_extractor.hh37
-rw-r--r--src/clients/inquisitio/pcre_matcher.cc54
-rw-r--r--src/clients/inquisitio/pcre_matcher.hh40
-rw-r--r--src/clients/inquisitio/text_matcher.cc54
-rw-r--r--src/clients/inquisitio/text_matcher.hh40
-rwxr-xr-xsrc/clients/inquisitio/version_TEST4
24 files changed, 1321 insertions, 31 deletions
diff --git a/configure.ac b/configure.ac
index 87f9c13..f8e0956 100644
--- a/configure.ac
+++ b/configure.ac
@@ -227,6 +227,7 @@ AM_CONDITIONAL([NEED_POINTER_WRAPPERS], test x$need_pointer_wrappers = "xyes")
dnl }}}
need_xml_check=
+need_pcrepp_check=
dnl {{{ we need libebt.
dnl don't use AC_CHECK_HEADER, it does silly things
@@ -471,15 +472,7 @@ AC_ARG_ENABLE([qa],
[ENABLE_QA=no
AC_MSG_RESULT([no])])
if test x"$ENABLE_QA" = "xyes" ; then
- AC_CHECK_PROG(HAVE_PRCEPLUSPLUS, [pcre++-config], [yes], [no])
- if test x"$HAVE_PRCEPLUSPLUS" = "xyes" ; then
- PCREPLUSPLUS_CFLAGS=`pcre++-config --cflags`
- AC_SUBST(PCREPLUSPLUS_CFLAGS)
- PCREPLUSPLUS_LIBS=`pcre++-config --libs`
- AC_SUBST(PCREPLUSPLUS_LIBS)
- else
- AC_MSG_ERROR([pcre++ (http://www.daemon.de/PCRE) is required if --enable-qa is used])
- fi
+ need_pcrepp_check=yes
need_xml_check=yes
AC_DEFINE([ENABLE_RUBY_QA], [1], [Enable QA support in ruby])
fi
@@ -503,18 +496,6 @@ AC_SUBST([ENABLE_GLSA])
AM_CONDITIONAL([ENABLE_GLSA], test "x$ENABLE_GLSA" = "xyes")
dnl }}}
-dnl {{{ libxml2 check
-NEED_XML=$need_xml_check
-if test "x$need_xml_check" = "xyes" ; then
- PKG_CHECK_MODULES(LIBXML2DEPS, [libxml-2.0 >= 2.6], [],
- [AC_MSG_ERROR([libxml2 (http://xmlsoft.org/) is required if --enable-qa or --enable-glsa is used])])
- AC_SUBST(LIBXML2DEPS_CFLAGS)
- AC_SUBST(LIBXML2DEPS_LIBS)
-fi
-AC_SUBST([NEED_XML])
-AM_CONDITIONAL([NEED_XML], test "x$NEED_XML" = "xyes")
-dnl }}}
-
dnl {{{ colourschemes
AC_MSG_CHECKING([whether we like pink])
AC_ARG_ENABLE([pink],
@@ -756,7 +737,7 @@ fi
dnl }}}
dnl {{{ clients
-ALL_CLIENTS="adjutrix contrarius gtkpaludis paludis qualudis"
+ALL_CLIENTS="adjutrix contrarius gtkpaludis inquisitio paludis qualudis"
DEFAULT_CLIENTS="adjutrix paludis"
if test x"$ENABLE_QA" = "xyes" ; then
DEFAULT_CLIENTS="$DEFAULT_CLIENTS qualudis"
@@ -775,6 +756,7 @@ AC_ARG_WITH([clients],
adjutrix A tool for tree querying
contrarius The cross toolchain creator
gtkpaludis The Gtk+ client (UNUSABLE)
+ inquisitio A search client
paludis The Paludis console client
qualudis The QA console client],
[clients="`echo $with_clients | tr ',' ' '`"],
@@ -784,10 +766,39 @@ AC_MSG_RESULT([$clients])
BUILD_CLIENTS="$clients"
AC_SUBST([ALL_CLIENTS])
AC_SUBST([BUILD_CLIENTS])
+
+if echo $clients | tr ' ' '\n' | grep '^inquisitio$' >/dev/null ; then
+ need_pcrepp_check=yes
+fi
dnl }}}
-dnl {{{ is sed gnu sed
+dnl {{{ libxml2 check
+NEED_XML=$need_xml_check
+if test "x$need_xml_check" = "xyes" ; then
+ PKG_CHECK_MODULES(LIBXML2DEPS, [libxml-2.0 >= 2.6], [],
+ [AC_MSG_ERROR([libxml2 (http://xmlsoft.org/) is required if --enable-qa or --enable-glsa is used])])
+ AC_SUBST(LIBXML2DEPS_CFLAGS)
+ AC_SUBST(LIBXML2DEPS_LIBS)
+fi
+AC_SUBST([NEED_XML])
+AM_CONDITIONAL([NEED_XML], test "x$NEED_XML" = "xyes")
+dnl }}}
+dnl {{{ pcrepp check
+if test "x$need_pcrepp_check" = "xyes" ; then
+ AC_CHECK_PROG(HAVE_PRCEPLUSPLUS, [pcre++-config], [yes], [no])
+ if test x"$HAVE_PRCEPLUSPLUS" = "xyes" ; then
+ PCREPLUSPLUS_CFLAGS=`pcre++-config --cflags`
+ AC_SUBST(PCREPLUSPLUS_CFLAGS)
+ PCREPLUSPLUS_LIBS=`pcre++-config --libs`
+ AC_SUBST(PCREPLUSPLUS_LIBS)
+ else
+ AC_MSG_ERROR([pcre++ (http://www.daemon.de/PCRE) is required if --enable-qa or --with-clients=inquisitio is used])
+ fi
+fi
+dnl }}}
+
+dnl {{{ is sed gnu sed
AC_MSG_CHECKING([if we need a sed wrapper])
AC_SUBST([NEED_SED_WRAPPER])
AC_CACHE_VAL(paludis_need_sed_wrapper,[sed --version &>/dev/null || paludis_need_sed_wrapper=yes])
@@ -912,6 +923,7 @@ AC_OUTPUT(
src/common_args/Makefile
src/clients/Makefile
src/clients/contrarius/Makefile
+ src/clients/inquisitio/Makefile
src/clients/paludis/Makefile
src/clients/gtkpaludis/Makefile
src/clients/gtkpaludis/cellrendererbutton/Makefile
diff --git a/misc/make_sr.bash b/misc/make_sr.bash
index dddd20e..7193bce 100755
--- a/misc/make_sr.bash
+++ b/misc/make_sr.bash
@@ -221,13 +221,13 @@ while read a ; do
echo " ///\\name Basic operations"
echo " ///\{"
echo
- echo " Param_${n}(const Empty &, $(make_const_ref "${t}" ) value_for_${n}) :"
+ echo " Param_${n}(const paludis::Empty &, $(make_const_ref "${t}" ) value_for_${n}) :"
echo " ${n}(value_for_${n})"
echo " {"
echo " }"
echo
echo " /// Constructor"
- echo " Param_${n}(const Empty &, const Param_${n} & other) :"
+ echo " Param_${n}(const paludis::Empty &, const Param_${n} & other) :"
echo " ${n}(other.${n})"
echo " {"
echo " }"
@@ -267,7 +267,7 @@ while read a ; do
echo " );"
echo " }"
echo
- echo " ParamNeeded_${n}(const Before_ & before, const Empty &) :"
+ echo " ParamNeeded_${n}(const Before_ & before, const paludis::Empty &) :"
echo " _before(before)"
echo " {"
echo " }"
@@ -292,7 +292,7 @@ while read a ; do
echo " >"
echo " class Params :"
for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
- echo " public Select<has_${want_keys[${k}]}_,"
+ echo " public paludis::Select<has_${want_keys[${k}]}_,"
echo " Param_${want_keys[${k}]},"
echo " ParamNeeded_${want_keys[${k}]}<"
echo -n " Params<"
@@ -323,7 +323,7 @@ while read a ; do
done
echo " >::Type,"
done
- echo " public Empty"
+ echo " public paludis::Empty"
echo " {"
echo " private:"
echo " Params();"
@@ -336,7 +336,7 @@ while read a ; do
for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
n=${want_keys[${k}]}
echo -n " "
- echo -n "const typename Select<has_${n}_, Param_${n}, Empty>::Type & value_for_${n}"
+ echo -n "const typename paludis::Select<has_${n}_, Param_${n}, paludis::Empty>::Type & value_for_${n}"
if [[ $(( ${k} + 1 )) -lt ${#want_keys[@]} ]] ; then
echo ","
else
@@ -345,7 +345,7 @@ while read a ; do
done
echo " ) :"
for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
- echo " Select<has_${want_keys[${k}]}_,"
+ echo " paludis::Select<has_${want_keys[${k}]}_,"
echo " Param_${want_keys[${k}]},"
echo " ParamNeeded_${want_keys[${k}]}<"
echo -n " Params<"
@@ -377,7 +377,7 @@ while read a ; do
echo " >::Type(*this, value_for_${want_keys[${k}]}),"
done
- echo " Empty()"
+ echo " paludis::Empty()"
echo " {"
echo " }"
echo
diff --git a/src/clients/inquisitio/Makefile.am b/src/clients/inquisitio/Makefile.am
new file mode 100644
index 0000000..8242ab9
--- /dev/null
+++ b/src/clients/inquisitio/Makefile.am
@@ -0,0 +1,89 @@
+AM_CXXFLAGS = -I$(top_srcdir) -I$(top_srcdir)/src @PALUDIS_CXXFLAGS@
+DEFS= \
+ -DSYSCONFDIR=\"$(sysconfdir)\" \
+ -DDATADIR=\"$(datadir)\" \
+ -DLIBEXECDIR=\"$(libexecdir)\" \
+ -DLIBDIR=\"$(libdir)\"
+
+SUBDIRS = .
+
+bin_PROGRAMS = inquisitio
+noinst_PROGRAMS = man-inquisitio
+noinst_DATA = inquisitio.html
+man_MANS = inquisitio.1
+
+inquisitio.1 : man-inquisitio
+ ./man-inquisitio > $@
+
+inquisitio.html : man-inquisitio
+ ./man-inquisitio --html > $@
+
+man_inquisitio_SOURCES = \
+ man_inquisitio.cc \
+ command_line.hh command_line.cc
+
+man_inquisitio_LDADD = \
+ $(top_builddir)/paludis/args/libpaludisargs.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/paludis/libpaludismanpagethings.la \
+ $(top_builddir)/src/common_args/libcommonargs.a \
+ $(top_builddir)/src/output/liboutput.a \
+ $(DYNAMIC_LD_LIBS) \
+ $(PCREPLUSPLUS_LIBS)
+
+inquisitio_SOURCES = \
+ command_line.hh command_line.cc \
+ matcher.hh matcher.cc \
+ pcre_matcher.hh pcre_matcher.cc \
+ text_matcher.hh text_matcher.cc \
+ extractor.hh extractor.cc \
+ description_extractor.hh description_extractor.cc \
+ name_extractor.hh name_extractor.cc \
+ do_search.hh do_search.cc \
+ inquisitio.cc
+
+inquisitio_LDADD = \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/args/libpaludisargs.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/paludis/environment/default/libpaludisdefaultenvironment.la \
+ $(top_builddir)/src/output/liboutput.a \
+ $(top_builddir)/src/common_args/libcommonargs.a \
+ $(DYNAMIC_LD_LIBS) \
+ $(PCREPLUSPLUS_LIBS)
+
+inquisitio_CXXFLAGS = $(PCREPLUSPLUS_CFLAGS)
+
+TESTS_ENVIRONMENT = env \
+ TEST_SCRIPT_DIR="$(srcdir)/" \
+ PALUDIS_NO_GLOBAL_HOOKS="yes" \
+ PALUDIS_NO_XTERM_TITLES="yes" \
+ PALUDIS_OPTIONS="" \
+ PALUDIS_EBUILD_DIR="`$(top_srcdir)/ebuild/utils/canonicalise $(top_srcdir)/ebuild/`" \
+ PALUDIS_EBUILD_DIR_FALLBACK="`$(top_srcdir)/ebuild/utils/canonicalise $(top_builddir)/ebuild/`" \
+ PALUDIS_REPOSITORY_SO_DIR="`$(top_srcdir)/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories`" \
+ SYSCONFDIR="$(sysconfdir)" \
+ bash $(top_srcdir)/test/run_test.sh bash
+
+TESTS = version_TEST help_TEST
+
+EXTRA_DIST = \
+ $(man_MANS) \
+ $(TESTS) \
+ matcher-sr.hh matcher-sr.cc matcher.sr
+
+CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda
+DISTCLEANFILES = $(man_MANS) $(noinst_DATA) matcher-sr.hh matcher-sr.cc
+MAINTAINERCLEANFILES = Makefile.in
+BUILT_SOURCES = matcher-sr.hh matcher-sr.cc
+
+built-sources : $(BUILT_SOURCES)
+ for s in `echo $(SUBDIRS) | tr -d .` ; do $(MAKE) -C $$s built-sources || exit 1 ; done
+
+matcher-sr.hh : matcher.sr $(top_srcdir)/misc/make_sr.bash
+ if ! $(top_srcdir)/misc/make_sr.bash --header $(srcdir)/matcher.sr > $@ ; then rm -f $@ ; exit 1 ; fi
+
+matcher-sr.cc : matcher.sr $(top_srcdir)/misc/make_sr.bash
+ if ! $(top_srcdir)/misc/make_sr.bash --source $(srcdir)/matcher.sr > $@ ; then rm -f $@ ; exit 1 ; fi
+
+
diff --git a/src/clients/inquisitio/command_line.cc b/src/clients/inquisitio/command_line.cc
new file mode 100644
index 0000000..9599f9a
--- /dev/null
+++ b/src/clients/inquisitio/command_line.cc
@@ -0,0 +1,96 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "command_line.hh"
+#include <paludis/name.hh>
+
+using namespace paludis;
+
+CommandLine::CommandLine() :
+ ArgsHandler(),
+
+ action_args(this, "Actions",
+ "Selects which basic action to perform. Exactly one action should "
+ "be specified."),
+ a_search(&action_args, "search", 's', "Search for a package"),
+ a_version(&action_args, "version", 'V', "Display program version"),
+ a_help(&action_args, "help", 'h', "Display program help"),
+
+ general_args(this, "General options",
+ "Options that are relevant for most or all actions."),
+ a_log_level(&general_args, "log-level", '\0'),
+ a_no_colour(&general_args, "no-colour", '\0', "Do not use colour"),
+ a_no_color(&a_no_colour, "no-color"),
+ a_config_suffix(&general_args, "config-suffix", 'c', "Config directory suffix"),
+
+ search_args(this, "Search options",
+ "Options that are relevant for the search action."),
+ a_matcher(&search_args, "matcher", 'm', "Which match algorithm to use",
+ paludis::args::EnumArg::EnumArgOptions
+ ("text", "Simple text match")
+ ("pcre", "Regular expression match using pcre"),
+ "text"),
+ a_extractors(&search_args, "extractors", 'e', "Which extractors to use",
+ paludis::args::StringSetArg::StringSetArgOptions
+ ("description", "Match against description (default)")
+ ("name", "Match against package name")
+ ("homepage", "Match against homepage")),
+
+ a_repository(&search_args, "repository", '\0', "Matches with this repository name only",
+ paludis::args::StringSetArg::StringSetArgOptions(), &paludis::RepositoryNameValidator::validate),
+ a_repository_format(&search_args, "repository-format", '\0', "Matches with this repository format only"),
+ a_category(&search_args, "category", '\0', "Matches with this category name only",
+ paludis::args::StringSetArg::StringSetArgOptions(), &paludis::CategoryNamePartValidator::validate),
+ a_package(&search_args, "package", '\0', "Matches with this package name only",
+ paludis::args::StringSetArg::StringSetArgOptions(), &paludis::PackageNamePartValidator::validate)
+{
+ add_usage_line("--search [search options] pattern ...");
+ add_usage_line("--info");
+ add_usage_line("--help");
+
+ add_environment_variable("INQUISITIO_OPTIONS", "Default command-line options.");
+}
+
+std::string
+CommandLine::app_name() const
+{
+ return "inquisitio";
+}
+
+std::string
+CommandLine::app_synopsis() const
+{
+ return "A search client for Paludis, the other package mangler";
+}
+
+std::string
+CommandLine::app_description() const
+{
+ return
+ "inquisitio is a search client for Paludis. It can find packages based upon a "
+ "number of different criteria including package name, description and homepage, "
+ "and using a number of different match techniques including simple text match, "
+ "approximate match and regular expression.";
+}
+
+CommandLine::~CommandLine()
+{
+}
+
+
diff --git a/src/clients/inquisitio/command_line.hh b/src/clients/inquisitio/command_line.hh
new file mode 100644
index 0000000..5ab240a
--- /dev/null
+++ b/src/clients/inquisitio/command_line.hh
@@ -0,0 +1,95 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_SRC_CLIENTS_INQUISITIO_COMMAND_LINE_HH
+#define PALUDIS_GUARD_SRC_CLIENTS_INQUISITIO_COMMAND_LINE_HH 1
+
+#include <paludis/args/args.hh>
+#include <paludis/util/instantiation_policy.hh>
+#include <src/common_args/log_level_arg.hh>
+
+/** \file
+ * Declarations for the CommandLine class.
+ */
+
+/**
+ * Our command line.
+ */
+class CommandLine :
+ public paludis::args::ArgsHandler,
+ public paludis::InstantiationPolicy<CommandLine, paludis::instantiation_method::SingletonTag>
+{
+ friend class paludis::InstantiationPolicy<CommandLine, paludis::instantiation_method::SingletonTag>;
+
+ private:
+ /// Constructor.
+ CommandLine();
+
+ /// Destructor.
+ ~CommandLine();
+
+ public:
+ ///\name Program information
+ ///\{
+
+ virtual std::string app_name() const;
+ virtual std::string app_synopsis() const;
+ virtual std::string app_description() const;
+
+ ///\}
+
+ /// \name Action arguments
+ ////{
+
+ paludis::args::ArgsGroup action_args;
+
+ paludis::args::SwitchArg a_search;
+ paludis::args::SwitchArg a_version;
+ paludis::args::SwitchArg a_help;
+
+ ///\}
+
+ /// \name General arguments
+ ///{
+
+ paludis::args::ArgsGroup general_args;
+ paludis::args::LogLevelArg a_log_level;
+ paludis::args::SwitchArg a_no_colour;
+ paludis::args::AliasArg a_no_color;
+ paludis::args::StringArg a_config_suffix;
+
+ ///}
+
+ ///\name Search arguments
+ ///\{
+
+ paludis::args::ArgsGroup search_args;
+ paludis::args::EnumArg a_matcher;
+ paludis::args::StringSetArg a_extractors;
+
+ paludis::args::StringSetArg a_repository;
+ paludis::args::StringSetArg a_repository_format;
+ paludis::args::StringSetArg a_category;
+ paludis::args::StringSetArg a_package;
+
+ ///\}
+};
+
+
+#endif
diff --git a/src/clients/inquisitio/description_extractor.cc b/src/clients/inquisitio/description_extractor.cc
new file mode 100644
index 0000000..1e2a506
--- /dev/null
+++ b/src/clients/inquisitio/description_extractor.cc
@@ -0,0 +1,54 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "description_extractor.hh"
+
+using namespace paludis;
+using namespace inquisitio;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<DescriptionExtractor>
+ {
+ const Environment * const env;
+
+ Implementation(const Environment & e) :
+ env(&e)
+ {
+ }
+ };
+}
+
+DescriptionExtractor::DescriptionExtractor(const Environment & e) :
+ PrivateImplementationPattern<DescriptionExtractor>(new Implementation<DescriptionExtractor>(e))
+{
+}
+
+DescriptionExtractor::~DescriptionExtractor()
+{
+}
+
+std::string
+DescriptionExtractor::operator() (const PackageDatabaseEntry & p) const
+{
+ return _imp->env->package_database()->fetch_repository(p.repository)->
+ version_metadata(p.name, p.version)->description;
+}
+
diff --git a/src/clients/inquisitio/description_extractor.hh b/src/clients/inquisitio/description_extractor.hh
new file mode 100644
index 0000000..aa8a305
--- /dev/null
+++ b/src/clients/inquisitio/description_extractor.hh
@@ -0,0 +1,39 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_SRC_CLIENTS_INQUISITIO_DESCRIPTION_EXTRACTOR_HH
+#define PALUDIS_GUARD_SRC_CLIENTS_INQUISITIO_DESCRIPTION_EXTRACTOR_HH 1
+
+#include <src/clients/inquisitio/extractor.hh>
+
+namespace inquisitio
+{
+ class DescriptionExtractor :
+ public Extractor,
+ private paludis::PrivateImplementationPattern<DescriptionExtractor>
+ {
+ public:
+ DescriptionExtractor(const paludis::Environment &);
+ virtual ~DescriptionExtractor();
+
+ std::string operator() (const paludis::PackageDatabaseEntry &) const;
+ };
+}
+
+#endif
diff --git a/src/clients/inquisitio/do_search.cc b/src/clients/inquisitio/do_search.cc
new file mode 100644
index 0000000..6c4dd69
--- /dev/null
+++ b/src/clients/inquisitio/do_search.cc
@@ -0,0 +1,120 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "do_search.hh"
+#include "command_line.hh"
+#include "matcher.hh"
+#include "extractor.hh"
+
+#include <paludis/environment.hh>
+#include <list>
+#include <iostream>
+
+using namespace paludis;
+using namespace inquisitio;
+
+int
+do_search(const Environment & env)
+{
+ std::list<std::tr1::shared_ptr<Matcher> > matchers;
+ std::list<std::tr1::shared_ptr<Extractor> > extractors;
+
+ for (CommandLine::ParametersIterator p(CommandLine::get_instance()->begin_parameters()),
+ p_end(CommandLine::get_instance()->end_parameters()) ; p != p_end ; ++p)
+ matchers.push_back(MatcherMaker::get_instance()->find_maker(
+ CommandLine::get_instance()->a_matcher.argument())(*p));
+
+ for (paludis::args::StringSetArg::Iterator p(CommandLine::get_instance()->a_extractors.begin_args()),
+ p_end(CommandLine::get_instance()->a_extractors.end_args()) ; p != p_end ; ++p)
+ extractors.push_back(ExtractorMaker::get_instance()->find_maker(*p)(env));
+
+ if (extractors.empty())
+ extractors.push_back(ExtractorMaker::get_instance()->find_maker("description")(env));
+
+ MatcherOptions opts(false);
+
+ for (IndirectIterator<PackageDatabase::RepositoryIterator, const Repository>
+ r(env.package_database()->begin_repositories()), r_end(env.package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ {
+ if (CommandLine::get_instance()->a_repository.specified())
+ if (CommandLine::get_instance()->a_repository.end_args() == std::find(
+ CommandLine::get_instance()->a_repository.begin_args(),
+ CommandLine::get_instance()->a_repository.end_args(),
+ stringify(r->name())))
+ continue;
+ if (CommandLine::get_instance()->a_repository_format.specified())
+ if (CommandLine::get_instance()->a_repository_format.end_args() == std::find(
+ CommandLine::get_instance()->a_repository_format.begin_args(),
+ CommandLine::get_instance()->a_repository_format.end_args(),
+ r->format()))
+ continue;
+
+ std::tr1::shared_ptr<const CategoryNamePartCollection> cat_names(r->category_names());
+ for (CategoryNamePartCollection::Iterator c(cat_names->begin()), c_end(cat_names->end()) ;
+ c != c_end ; ++c)
+ {
+ if (CommandLine::get_instance()->a_category.specified())
+ if (CommandLine::get_instance()->a_category.end_args() == std::find(
+ CommandLine::get_instance()->a_category.begin_args(),
+ CommandLine::get_instance()->a_category.end_args(),
+ stringify(*c)))
+ continue;
+
+ std::tr1::shared_ptr<const QualifiedPackageNameCollection> pkg_names(r->package_names(*c));
+ for (QualifiedPackageNameCollection::Iterator p(pkg_names->begin()), p_end(pkg_names->end()) ;
+ p != p_end ; ++p)
+ {
+ std::tr1::shared_ptr<const PackageDatabaseEntryCollection>
+ entries(env.package_database()->query(PackageDepAtom(*p), is_any, qo_order_by_version)),
+ preferred_entries(env.package_database()->query(PackageDepAtom(*p), is_installed_only, qo_order_by_version));
+
+ if (entries->empty())
+ continue;
+ if (preferred_entries->empty())
+ preferred_entries = entries;
+
+ PackageDatabaseEntry display_entry(*preferred_entries->last());
+ for (PackageDatabaseEntryCollection::Iterator i(preferred_entries->begin()),
+ i_end(preferred_entries->end()) ; i != i_end ; ++i)
+ if (! env.mask_reasons(*i).any())
+ display_entry = *i;
+
+ bool match(false);
+ for (std::list<std::tr1::shared_ptr<Extractor> >::const_iterator x(extractors.begin()),
+ x_end(extractors.end()) ; x != x_end && ! match ; ++x)
+ {
+ std::string xx((**x)(display_entry));
+ for (std::list<std::tr1::shared_ptr<Matcher> >::const_iterator m(matchers.begin()),
+ m_end(matchers.end()) ; m != m_end && ! match ; ++m)
+ if ((**m)(xx, opts))
+ match = true;
+ }
+
+ if (! match)
+ continue;
+
+ std::cout << display_entry << std::endl;
+ }
+ }
+ }
+
+ return 0;
+}
+
diff --git a/src/clients/inquisitio/do_search.hh b/src/clients/inquisitio/do_search.hh
new file mode 100644
index 0000000..9b9049f
--- /dev/null
+++ b/src/clients/inquisitio/do_search.hh
@@ -0,0 +1,30 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_SRC_CLIENTS_INQUISITIO_DO_SEARCH_HH
+#define PALUDIS_GUARD_SRC_CLIENTS_INQUISITIO_DO_SEARCH_HH 1
+
+namespace paludis
+{
+ class Environment;
+}
+
+int do_search(const paludis::Environment & env);
+
+#endif
diff --git a/src/clients/inquisitio/extractor.cc b/src/clients/inquisitio/extractor.cc
new file mode 100644
index 0000000..0a2d763
--- /dev/null
+++ b/src/clients/inquisitio/extractor.cc
@@ -0,0 +1,55 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "extractor.hh"
+#include "description_extractor.hh"
+#include "name_extractor.hh"
+
+using namespace inquisitio;
+using namespace paludis;
+
+NoSuchExtractorError::NoSuchExtractorError(const std::string & m) throw () :
+ Exception("No such extractor '" + m + "'")
+{
+}
+
+namespace
+{
+ template <typename M_>
+ std::tr1::shared_ptr<Extractor>
+ make(const Environment & e)
+ {
+ return std::tr1::shared_ptr<Extractor>(new M_(e));
+ }
+}
+
+ExtractorMaker::ExtractorMaker()
+{
+ register_maker("description", &make<DescriptionExtractor>);
+ register_maker("name", &make<NameExtractor>);
+}
+
+Extractor::Extractor()
+{
+}
+
+Extractor::~Extractor()
+{
+}
+
diff --git a/src/clients/inquisitio/extractor.hh b/src/clients/inquisitio/extractor.hh
new file mode 100644
index 0000000..6c53349
--- /dev/null
+++ b/src/clients/inquisitio/extractor.hh
@@ -0,0 +1,64 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_SRC_CLIENTS_INQUISITIO_EXTRACTOR_HH
+#define PALUDIS_GUARD_SRC_CLIENTS_INQUISITIO_EXTRACTOR_HH 1
+
+#include <string>
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/util/virtual_constructor.hh>
+#include <paludis/package_database_entry.hh>
+#include <paludis/environment.hh>
+
+namespace inquisitio
+{
+ class Extractor :
+ private paludis::InstantiationPolicy<Extractor, paludis::instantiation_method::NonCopyableTag>
+ {
+ protected:
+ Extractor();
+
+ public:
+ virtual ~Extractor();
+
+ virtual std::string operator() (const paludis::PackageDatabaseEntry &) const = 0;
+ };
+
+ class NoSuchExtractorError :
+ public paludis::Exception
+ {
+ public:
+ NoSuchExtractorError(const std::string &) throw ();
+ };
+
+ class ExtractorMaker :
+ public paludis::InstantiationPolicy<ExtractorMaker, paludis::instantiation_method::SingletonTag>,
+ public paludis::VirtualConstructor<
+ std::string,
+ std::tr1::shared_ptr<Extractor> (*) (const paludis::Environment &),
+ paludis::virtual_constructor_not_found::ThrowException<NoSuchExtractorError> >
+ {
+ friend class paludis::InstantiationPolicy<ExtractorMaker, paludis::instantiation_method::SingletonTag>;
+
+ private:
+ ExtractorMaker();
+ };
+}
+
+#endif
diff --git a/src/clients/inquisitio/help_TEST b/src/clients/inquisitio/help_TEST
new file mode 100755
index 0000000..a71a515
--- /dev/null
+++ b/src/clients/inquisitio/help_TEST
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+PALUDIS_SKIP_CONFIG=yes ./inquisitio --help
+
diff --git a/src/clients/inquisitio/inquisitio.cc b/src/clients/inquisitio/inquisitio.cc
new file mode 100644
index 0000000..30770ac
--- /dev/null
+++ b/src/clients/inquisitio/inquisitio.cc
@@ -0,0 +1,165 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "command_line.hh"
+#include "do_search.hh"
+
+#include <iostream>
+#include <iomanip>
+#include <cstdlib>
+
+#include <paludis/about.hh>
+#include <paludis/util/join.hh>
+#include <paludis/environment/default/default_environment.hh>
+#include <paludis/environment/default/default_config.hh>
+
+#include <src/output/colour.hh>
+#include <src/common_args/do_help.hh>
+
+using namespace paludis;
+using std::cout;
+using std::cerr;
+using std::endl;
+
+namespace
+{
+ struct DoVersion
+ {
+ };
+
+ void display_version()
+ {
+ cout << "inquisitio" << " " << PALUDIS_VERSION_MAJOR << "."
+ << PALUDIS_VERSION_MINOR << "." << PALUDIS_VERSION_MICRO;
+ if (! std::string(PALUDIS_SUBVERSION_REVISION).empty())
+ cout << " svn " << PALUDIS_SUBVERSION_REVISION;
+ cout << endl << endl;
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+ Context context("In program " + join(argv, argv + argc, " ") + ":");
+
+ try
+ {
+ CommandLine::get_instance()->run(argc, argv, "inquisitio", "INQUISITIO_OPTIONS", "INQUISITIO_CMDLINE");
+ set_use_colour(! CommandLine::get_instance()->a_no_color.specified());
+
+ if (CommandLine::get_instance()->a_help.specified())
+ throw args::DoHelp();
+
+ if (CommandLine::get_instance()->a_version.specified())
+ throw DoVersion();
+
+ if (CommandLine::get_instance()->a_log_level.specified())
+ Log::get_instance()->set_log_level(CommandLine::get_instance()->a_log_level.option());
+ else
+ Log::get_instance()->set_log_level(ll_qa);
+
+ Log::get_instance()->set_program_name(argv[0]);
+
+ /* need an action */
+ if (1 != (CommandLine::get_instance()->a_search.specified() +
+ CommandLine::get_instance()->a_version.specified()))
+ throw args::DoHelp("you should specify exactly one action");
+
+ std::string paludis_command(argv[0]);
+ if (CommandLine::get_instance()->a_config_suffix.specified())
+ {
+ DefaultConfig::set_config_suffix(CommandLine::get_instance()->a_config_suffix.argument());
+ paludis_command.append(" --" + CommandLine::get_instance()->a_config_suffix.long_name() + " " +
+ CommandLine::get_instance()->a_config_suffix.argument());
+ }
+
+ paludis_command.append(" --" + CommandLine::get_instance()->a_log_level.long_name() + " " +
+ CommandLine::get_instance()->a_log_level.argument());
+
+ if (CommandLine::get_instance()->a_no_color.specified())
+ paludis_command.append(" --" + CommandLine::get_instance()->a_no_color.long_name());
+
+ DefaultConfig::get_instance()->set_paludis_command(paludis_command);
+
+ if (CommandLine::get_instance()->a_search.specified())
+ {
+ if (CommandLine::get_instance()->begin_parameters() == CommandLine::get_instance()->end_parameters())
+ throw args::DoHelp("search action takes at least one parameter");
+
+ return do_search(*DefaultEnvironment::get_instance());
+ }
+
+ throw InternalError(__PRETTY_FUNCTION__, "no action?");
+ }
+ catch (const DoVersion &)
+ {
+ display_version();
+ cout << endl;
+ cout << "Paludis comes with ABSOLUTELY NO WARRANTY. Paludis is free software, and you" << endl;
+ cout << "are welcome to redistribute it under the terms of the GNU General Public" << endl;
+ cout << "License, version 2." << endl;
+
+ return EXIT_SUCCESS;
+ }
+ catch (const paludis::args::ArgsError & e)
+ {
+ cerr << "Usage error: " << e.message() << endl;
+ cerr << "Try " << argv[0] << " --help" << endl;
+ return EXIT_FAILURE;
+ }
+ catch (const args::DoHelp & h)
+ {
+ if (h.message.empty())
+ {
+ cout << "Usage: " << argv[0] << " [options]" << endl;
+ cout << endl;
+ cout << *CommandLine::get_instance();
+ return EXIT_SUCCESS;
+ }
+ else
+ {
+ cerr << "Usage error: " << h.message << endl;
+ cerr << "Try " << argv[0] << " --help" << endl;
+ return EXIT_FAILURE;
+ }
+ }
+ catch (const Exception & e)
+ {
+ cout << endl;
+ cerr << "Unhandled exception:" << endl
+ << " * " << e.backtrace("\n * ")
+ << e.message() << " (" << e.what() << ")" << endl;
+ return EXIT_FAILURE;
+ }
+ catch (const std::exception & e)
+ {
+ cout << endl;
+ cerr << "Unhandled exception:" << endl
+ << " * " << e.what() << endl;
+ return EXIT_FAILURE;
+ }
+ catch (...)
+ {
+ cout << endl;
+ cerr << "Unhandled exception:" << endl
+ << " * Unknown exception type. Ouch..." << endl;
+ return EXIT_FAILURE;
+ }
+}
+
diff --git a/src/clients/inquisitio/man_inquisitio.cc b/src/clients/inquisitio/man_inquisitio.cc
new file mode 100644
index 0000000..377366a
--- /dev/null
+++ b/src/clients/inquisitio/man_inquisitio.cc
@@ -0,0 +1,70 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "command_line.hh"
+#include <paludis/args/man.hh>
+
+#include <iostream>
+#include <cstdlib>
+
+using std::cout;
+using std::endl;
+
+namespace
+{
+ struct ManCommandLine :
+ paludis::args::ArgsHandler
+ {
+ paludis::args::ArgsGroup group;
+ paludis::args::SwitchArg a_html;
+
+ ManCommandLine() :
+ group(this, "", ""),
+ a_html(&group, "html", '\0', "")
+ {
+ }
+
+ virtual std::string app_name() const
+ {
+ return "";
+ }
+
+ virtual std::string app_description() const
+ {
+ return "";
+ }
+
+ virtual std::string app_synopsis() const
+ {
+ return "";
+ }
+ };
+}
+
+int
+main(int argc, char * argv[])
+{
+ ManCommandLine cmdline;
+ cmdline.run(argc, argv, "", "", "");
+
+ paludis::args::generate_man(cout, CommandLine::get_instance(),
+ cmdline.a_html.specified() ? paludis::args::mf_html : paludis::args::mf_man);
+ return EXIT_SUCCESS;
+}
+
diff --git a/src/clients/inquisitio/matcher.cc b/src/clients/inquisitio/matcher.cc
new file mode 100644
index 0000000..16a0375
--- /dev/null
+++ b/src/clients/inquisitio/matcher.cc
@@ -0,0 +1,57 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "matcher.hh"
+#include "pcre_matcher.hh"
+#include "text_matcher.hh"
+
+using namespace inquisitio;
+using namespace paludis;
+
+#include <src/clients/inquisitio/matcher-sr.cc>
+
+Matcher::Matcher()
+{
+}
+
+Matcher::~Matcher()
+{
+}
+
+NoSuchMatcherError::NoSuchMatcherError(const std::string & msg) throw () :
+ Exception("No such matcher '" + msg + "'")
+{
+}
+
+namespace
+{
+ template <typename M_>
+ static std::tr1::shared_ptr<Matcher>
+ make(const std::string & s)
+ {
+ return std::tr1::shared_ptr<Matcher>(new M_(s));
+ }
+}
+
+MatcherMaker::MatcherMaker()
+{
+ register_maker("pcre", &make<PCREMatcher>);
+ register_maker("text", &make<TextMatcher>);
+}
+
diff --git a/src/clients/inquisitio/matcher.hh b/src/clients/inquisitio/matcher.hh
new file mode 100644
index 0000000..d518e50
--- /dev/null
+++ b/src/clients/inquisitio/matcher.hh
@@ -0,0 +1,66 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_SRC_CLIENTS_INQUISITIO_MATCHER_HH
+#define PALUDIS_GUARD_SRC_CLIENTS_INQUISITIO_MATCHER_HH 1
+
+#include <string>
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/util/sr.hh>
+#include <paludis/util/virtual_constructor.hh>
+
+namespace inquisitio
+{
+
+#include <src/clients/inquisitio/matcher-sr.hh>
+
+ class Matcher :
+ private paludis::InstantiationPolicy<Matcher, paludis::instantiation_method::NonCopyableTag>
+ {
+ protected:
+ Matcher();
+
+ public:
+ virtual ~Matcher();
+
+ virtual bool operator() (const std::string &, const MatcherOptions &) const = 0;
+ };
+
+ class NoSuchMatcherError :
+ public paludis::Exception
+ {
+ public:
+ NoSuchMatcherError(const std::string &) throw ();
+ };
+
+ class MatcherMaker :
+ public paludis::InstantiationPolicy<MatcherMaker, paludis::instantiation_method::SingletonTag>,
+ public paludis::VirtualConstructor<
+ std::string,
+ std::tr1::shared_ptr<Matcher> (*) (const std::string &),
+ paludis::virtual_constructor_not_found::ThrowException<NoSuchMatcherError> >
+ {
+ friend class paludis::InstantiationPolicy<MatcherMaker, paludis::instantiation_method::SingletonTag>;
+
+ private:
+ MatcherMaker();
+ };
+}
+
+#endif
diff --git a/src/clients/inquisitio/matcher.sr b/src/clients/inquisitio/matcher.sr
new file mode 100644
index 0000000..8b0dee8
--- /dev/null
+++ b/src/clients/inquisitio/matcher.sr
@@ -0,0 +1,11 @@
+#!/bin/bash
+# vim: set sw=4 sts=4 et :
+
+make_class_MatcherOptions()
+{
+ key full_match bool
+
+ allow_named_args
+}
+
+
diff --git a/src/clients/inquisitio/name_extractor.cc b/src/clients/inquisitio/name_extractor.cc
new file mode 100644
index 0000000..780bb12
--- /dev/null
+++ b/src/clients/inquisitio/name_extractor.cc
@@ -0,0 +1,34 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "name_extractor.hh"
+
+using namespace inquisitio;
+using namespace paludis;
+
+NameExtractor::NameExtractor(const paludis::Environment &)
+{
+}
+
+std::string
+NameExtractor::operator() (const PackageDatabaseEntry & p) const
+{
+ return stringify(p.name);
+}
+
diff --git a/src/clients/inquisitio/name_extractor.hh b/src/clients/inquisitio/name_extractor.hh
new file mode 100644
index 0000000..94977c9
--- /dev/null
+++ b/src/clients/inquisitio/name_extractor.hh
@@ -0,0 +1,37 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_SRC_CLIENTS_INQUISITIO_NAME_EXTRACTOR_HH
+#define PALUDIS_GUARD_SRC_CLIENTS_INQUISITIO_NAME_EXTRACTOR_HH 1
+
+#include <src/clients/inquisitio/extractor.hh>
+
+namespace inquisitio
+{
+ class NameExtractor :
+ public Extractor
+ {
+ public:
+ NameExtractor(const paludis::Environment &);
+
+ std::string operator() (const paludis::PackageDatabaseEntry &) const;
+ };
+}
+
+#endif
diff --git a/src/clients/inquisitio/pcre_matcher.cc b/src/clients/inquisitio/pcre_matcher.cc
new file mode 100644
index 0000000..45b3577
--- /dev/null
+++ b/src/clients/inquisitio/pcre_matcher.cc
@@ -0,0 +1,54 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "pcre_matcher.hh"
+#include <pcre++.h>
+
+using namespace paludis;
+using namespace inquisitio;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<PCREMatcher>
+ {
+ mutable pcrepp::Pcre::Pcre pattern;
+
+ Implementation(const std::string & s) :
+ pattern(s)
+ {
+ }
+ };
+}
+
+PCREMatcher::PCREMatcher(const std::string & s) :
+ PrivateImplementationPattern<PCREMatcher>(new Implementation<PCREMatcher>(s))
+{
+}
+
+bool
+PCREMatcher::operator() (const std::string & s, const MatcherOptions &) const
+{
+ return _imp->pattern.search(s);
+}
+
+PCREMatcher::~PCREMatcher()
+{
+}
+
diff --git a/src/clients/inquisitio/pcre_matcher.hh b/src/clients/inquisitio/pcre_matcher.hh
new file mode 100644
index 0000000..a67cfce
--- /dev/null
+++ b/src/clients/inquisitio/pcre_matcher.hh
@@ -0,0 +1,40 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_SRC_CLIENTS_INQUISITIO_PCRE_MATCHER_HH
+#define PALUDIS_GUARD_SRC_CLIENTS_INQUISITIO_PCRE_MATCHER_HH 1
+
+#include <src/clients/inquisitio/matcher.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+
+namespace inquisitio
+{
+ class PCREMatcher :
+ public Matcher,
+ private paludis::PrivateImplementationPattern<PCREMatcher>
+ {
+ public:
+ PCREMatcher(const std::string &);
+ virtual ~PCREMatcher();
+
+ bool operator() (const std::string &, const MatcherOptions &) const;
+ };
+}
+
+#endif
diff --git a/src/clients/inquisitio/text_matcher.cc b/src/clients/inquisitio/text_matcher.cc
new file mode 100644
index 0000000..c913b58
--- /dev/null
+++ b/src/clients/inquisitio/text_matcher.cc
@@ -0,0 +1,54 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "text_matcher.hh"
+
+using namespace paludis;
+using namespace inquisitio;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<TextMatcher>
+ {
+ std::string pattern;
+
+ Implementation(const std::string & s) :
+ pattern(s)
+ {
+ }
+ };
+}
+
+TextMatcher::TextMatcher(const std::string & s) :
+ PrivateImplementationPattern<TextMatcher>(new Implementation<TextMatcher>(s))
+{
+}
+
+bool
+TextMatcher::operator() (const std::string & s, const MatcherOptions &) const
+{
+ return std::string::npos != s.find(_imp->pattern);
+}
+
+TextMatcher::~TextMatcher()
+{
+}
+
+
diff --git a/src/clients/inquisitio/text_matcher.hh b/src/clients/inquisitio/text_matcher.hh
new file mode 100644
index 0000000..a317c89
--- /dev/null
+++ b/src/clients/inquisitio/text_matcher.hh
@@ -0,0 +1,40 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_SRC_CLIENTS_INQUISITIO_TEXT_MATCHER_HH
+#define PALUDIS_GUARD_SRC_CLIENTS_INQUISITIO_TEXT_MATCHER_HH 1
+
+#include <src/clients/inquisitio/matcher.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+
+namespace inquisitio
+{
+ class TextMatcher :
+ public Matcher,
+ private paludis::PrivateImplementationPattern<TextMatcher>
+ {
+ public:
+ TextMatcher(const std::string &);
+ virtual ~TextMatcher();
+
+ bool operator() (const std::string &, const MatcherOptions &) const;
+ };
+}
+
+#endif
diff --git a/src/clients/inquisitio/version_TEST b/src/clients/inquisitio/version_TEST
new file mode 100755
index 0000000..5b7c634
--- /dev/null
+++ b/src/clients/inquisitio/version_TEST
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+PALUDIS_SKIP_CONFIG=yes ./inquisitio --version
+