aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-06 04:37:34 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-06 04:37:34 +0000
commit1482e34f6d87c6332f6aa9e2419f9a8e160fc36f (patch)
tree43fa077ea49929aa826afc91fa6b609611c09373
parentfd1b87319077b98fd7451c19b32042b26e882ba1 (diff)
downloadpaludis-1482e34f6d87c6332f6aa9e2419f9a8e160fc36f.tar.gz
paludis-1482e34f6d87c6332f6aa9e2419f9a8e160fc36f.tar.xz
Add in qualudis skeleton code
-rw-r--r--configure.ac1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/qualudis/Makefile.am22
-rw-r--r--src/qualudis/qualudis.cc164
-rw-r--r--src/qualudis/qualudis_command_line.cc35
-rw-r--r--src/qualudis/qualudis_command_line.hh42
6 files changed, 265 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 7e12807..a696281 100644
--- a/configure.ac
+++ b/configure.ac
@@ -286,6 +286,7 @@ AC_OUTPUT(
paludis/hashed_containers.hh
paludis/args/Makefile
src/Makefile
+ src/qualudis/Makefile
test/Makefile
)
dnl }}}
diff --git a/src/Makefile.am b/src/Makefile.am
index 760ab37..43ed99e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,6 +2,7 @@ CLEANFILES = *~ version_TEST
MAINTAINERCLEANFILES = Makefile.in
AM_CXXFLAGS = -I$(top_srcdir)
DEFS=-DSYSCONFDIR=\"$(sysconfdir)\" -DLIBEXECDIR=\"$(libexecdir)\"
+SUBDIRS = . qualudis
bin_PROGRAMS = paludis
noinst_PROGRAMS = check_deps_exist find_self_circular_dependencies
diff --git a/src/qualudis/Makefile.am b/src/qualudis/Makefile.am
new file mode 100644
index 0000000..eab366b
--- /dev/null
+++ b/src/qualudis/Makefile.am
@@ -0,0 +1,22 @@
+CLEANFILES = *~ version_TEST
+MAINTAINERCLEANFILES = Makefile.in
+AM_CXXFLAGS = -I$(top_srcdir)
+DEFS=-DSYSCONFDIR=\"$(sysconfdir)\" -DLIBEXECDIR=\"$(libexecdir)\"
+SUBDIRS = .
+
+bin_PROGRAMS = qualudis
+
+qualudis_SOURCES = \
+ qualudis_command_line.hh qualudis_command_line.cc \
+ qualudis.cc
+
+qualudis_LDADD = \
+ $(top_builddir)/paludis/libpaludis.a \
+ $(top_builddir)/paludis/args/libpaludisargs.a
+
+TESTS_ENVIRONMENT = env TEST_SCRIPT_DIR="$(srcdir)/" $(SHELL) $(top_srcdir)/test/run_test.sh bash
+TESTS = version_TEST
+
+version_TEST :
+ echo -e "#!/bin/sh\n./qualudis --version" > $@
+
diff --git a/src/qualudis/qualudis.cc b/src/qualudis/qualudis.cc
new file mode 100644
index 0000000..0c10199
--- /dev/null
+++ b/src/qualudis/qualudis.cc
@@ -0,0 +1,164 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.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 <paludis/paludis.hh>
+#include <paludis/args/args.hh>
+
+#include <cstdlib>
+#include <iostream>
+
+#include "qualudis_command_line.hh"
+#include "config.h"
+
+using namespace paludis;
+using std::cout;
+using std::cerr;
+using std::endl;
+
+struct DoHelp
+{
+ const std::string message;
+
+ DoHelp(const std::string & m = "") :
+ message(m)
+ {
+ }
+};
+
+struct DoVersion
+{
+};
+
+int
+do_check()
+{
+ return EXIT_SUCCESS;
+}
+
+int main(int argc, char *argv[])
+{
+ Context context("In main program:");
+
+ try
+ {
+ QualudisCommandLine::get_instance()->run(argc, argv);
+
+ if (QualudisCommandLine::get_instance()->a_help.specified())
+ throw DoHelp();
+
+ if (1 != (QualudisCommandLine::get_instance()->a_check.specified() +
+ QualudisCommandLine::get_instance()->a_version.specified()))
+ throw DoHelp("you should specify exactly one action");
+
+ if (QualudisCommandLine::get_instance()->a_version.specified())
+ throw DoVersion();
+
+ if (QualudisCommandLine::get_instance()->a_check.specified())
+ {
+ if (! QualudisCommandLine::get_instance()->empty())
+ throw DoHelp("check action takes no parameters");
+
+ return do_check();
+ }
+
+ throw InternalError(__PRETTY_FUNCTION__, "no action?");
+ }
+ catch (const DoVersion &)
+ {
+ cout << "qualudis, part of " << PALUDIS_PACKAGE << " " << PALUDIS_VERSION_MAJOR << "."
+ << PALUDIS_VERSION_MINOR << "." << PALUDIS_VERSION_MICRO;
+ if (! std::string(PALUDIS_SUBVERSION_REVISION).empty())
+ cout << " svn " << PALUDIS_SUBVERSION_REVISION;
+ cout << endl << endl;
+ cout << "Built by " << PALUDIS_BUILD_USER << "@" << PALUDIS_BUILD_HOST
+ << " on " << PALUDIS_BUILD_DATE << endl;
+ cout << "CXX: " << PALUDIS_BUILD_CXX
+#if defined(__ICC)
+ << " " << __ICC
+#elif defined(__VERSION__)
+ << " " << __VERSION__
+#endif
+ << endl;
+ cout << "CXXFLAGS: " << PALUDIS_BUILD_CXXFLAGS << endl;
+ cout << "LDFLAGS: " << PALUDIS_BUILD_LDFLAGS << endl;
+ cout << "SYSCONFDIR: " << SYSCONFDIR << endl;
+ cout << "LIBEXECDIR: " << LIBEXECDIR << endl;
+ cout << "stdlib: "
+#if defined(__GLIBCXX__)
+# define XSTRINGIFY(x) #x
+# define STRINGIFY(x) XSTRINGIFY(x)
+ << "GNU libstdc++ " << STRINGIFY(__GLIBCXX__)
+#endif
+ << endl;
+
+ cout << "libebt: " << LIBEBT_VERSION_MAJOR << "." << LIBEBT_VERSION_MINOR
+ << "." << LIBEBT_VERSION_MICRO << endl;
+ 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 DoHelp & h)
+ {
+ if (h.message.empty())
+ {
+ cout << "Usage: " << argv[0] << " [options]" << endl;
+ cout << endl;
+ cout << *QualudisCommandLine::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/qualudis/qualudis_command_line.cc b/src/qualudis/qualudis_command_line.cc
new file mode 100644
index 0000000..57edd17
--- /dev/null
+++ b/src/qualudis/qualudis_command_line.cc
@@ -0,0 +1,35 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.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 "qualudis_command_line.hh"
+
+QualudisCommandLine::QualudisCommandLine() :
+ ArgsHandler(),
+
+ action_args(this, "Actions (specify exactly one)"),
+ a_check(&action_args, "check", 'c', "Check the current directory"),
+ a_version(&action_args, "version", 'V', "Display program version"),
+ a_help(&action_args, "help", 'h', "Display program help")
+{
+}
+
+QualudisCommandLine::~QualudisCommandLine()
+{
+}
+
diff --git a/src/qualudis/qualudis_command_line.hh b/src/qualudis/qualudis_command_line.hh
new file mode 100644
index 0000000..93b03fb
--- /dev/null
+++ b/src/qualudis/qualudis_command_line.hh
@@ -0,0 +1,42 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#ifndef PALUDIS_GUARD_SRC_QUALUDIS_QUALUDIS_COMMAND_LINE_HH
+#define PALUDIS_GUARD_SRC_QUALUDIS_QUALUDIS_COMMAND_LINE_HH 1
+
+#include <paludis/args/args.hh>
+#include <paludis/instantiation_policy.hh>
+
+class QualudisCommandLine :
+ public paludis::args::ArgsHandler,
+ public paludis::InstantiationPolicy<QualudisCommandLine, paludis::instantiation_method::SingletonAsNeededTag>
+{
+ friend class paludis::InstantiationPolicy<QualudisCommandLine, paludis::instantiation_method::SingletonAsNeededTag>;
+
+ private:
+ /// Constructor.
+ QualudisCommandLine();
+
+ /// Destructor.
+ ~QualudisCommandLine();
+
+ public:
+ /// \name Action arguments
+ ///{
+
+ /// Action arguments.
+ paludis::args::ArgsGroup action_args;
+
+ /// --check
+ paludis::args::SwitchArg a_check;
+
+ /// --version
+ paludis::args::SwitchArg a_version;
+
+ /// --help
+ paludis::args::SwitchArg a_help;
+
+ ///}
+};
+
+
+#endif