aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-28 20:17:40 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-28 20:17:40 +0000
commit1e161df7be498bf1e2820abc9de7310b4a83f7ca (patch)
treecf4e3cd880e5c59c41608e3f4c8a3af61af65cc0
parentd2e1ff378fdaa5f1724325057b178fa6a9cd7b71 (diff)
downloadpaludis-1e161df7be498bf1e2820abc9de7310b4a83f7ca.tar.gz
paludis-1e161df7be498bf1e2820abc9de7310b4a83f7ca.tar.xz
More common args
-rw-r--r--src/clients/paludis/command_line.cc84
-rw-r--r--src/clients/paludis/command_line.hh13
-rw-r--r--src/common_args/Makefile.am1
-rw-r--r--src/common_args/deps_option_arg.cc83
-rw-r--r--src/common_args/deps_option_arg.hh44
5 files changed, 163 insertions, 62 deletions
diff --git a/src/clients/paludis/command_line.cc b/src/clients/paludis/command_line.cc
index 66c1d8c..d7a333d 100644
--- a/src/clients/paludis/command_line.cc
+++ b/src/clients/paludis/command_line.cc
@@ -19,6 +19,8 @@
#include "command_line.hh"
+using namespace paludis;
+
CommandLine::CommandLine() :
ArgsHandler(),
@@ -80,13 +82,13 @@ CommandLine::CommandLine() :
a_debug_build(&install_args, "debug-build", '\0'),
a_fetch(&install_args, "fetch", 'f', "Only fetch sources; don't install anything"),
a_show_install_reasons(&install_args, "show-install-reasons", '\0', "Show why packages are being installed",
- paludis::args::EnumArg::EnumArgOptions
+ args::EnumArg::EnumArgOptions
("none", "Don't show any information")
("summary", "Show a summary")
("full", "Show full output (can be very verbose)"),
"none"),
a_show_use_descriptions(&install_args, "show-use-descriptions", '\0', "Show descriptions of USE flags",
- paludis::args::EnumArg::EnumArgOptions
+ args::EnumArg::EnumArgOptions
("none", "Don't show any descriptions")
("new", "Show for new use flags")
("changed", "Show for new and changed flags")
@@ -101,82 +103,52 @@ CommandLine::CommandLine() :
"Modify dependency list generation behaviour. Use with caution."),
dl_reinstall(&dl_args, "dl-reinstall", '\0', "When to reinstall packages",
- paludis::args::EnumArg::EnumArgOptions
+ args::EnumArg::EnumArgOptions
("never", "Never")
("always", "Always")
("if-use-changed", "If USE flags have changed"),
"never"),
dl_reinstall_scm(&dl_args, "dl-reinstall-scm", '\0', "When to reinstall scm packages",
- paludis::args::EnumArg::EnumArgOptions
+ args::EnumArg::EnumArgOptions
("never", "Never")
("always", "Always")
("daily", "If they are over a day old")
("weekly", "If they are over a week old"),
"never"),
dl_upgrade(&dl_args, "dl-upgrade", '\0', "When to upgrade packages",
- paludis::args::EnumArg::EnumArgOptions
+ args::EnumArg::EnumArgOptions
("always", "Always")
("as-needed", "As needed"),
"always"),
- dl_installed_deps_pre(&dl_args, "dl-installed-deps-pre", '\0', "How to handle pre dependencies for installed packages",
- paludis::args::EnumArg::EnumArgOptions
- ("pre", "As pre dependencies")
- ("pre-or-post", "As pre dependencies, or post depenencies where needed")
- ("post", "As post dependencies")
- ("try-post", "As post dependencies, with no error for failures")
- ("discard", "Discard"),
- "discard"),
- dl_installed_deps_runtime(&dl_args, "dl-installed-deps-runtime", '\0', "How to handle runtime dependencies for installed packages",
- paludis::args::EnumArg::EnumArgOptions
- ("pre", "As pre dependencies")
- ("pre-or-post", "As pre dependencies, or post depenencies where needed")
- ("post", "As post dependencies")
- ("try-post", "As post dependencies, with no error for failures")
- ("discard", "Discard"),
- "try-post"),
- dl_installed_deps_post(&dl_args, "dl-installed-deps-post", '\0', "How to handle post dependencies for installed packages",
- paludis::args::EnumArg::EnumArgOptions
- ("pre", "As pre dependencies")
- ("pre-or-post", "As pre dependencies, or post depenencies where needed")
- ("post", "As post dependencies")
- ("try-post", "As post dependencies, with no error for failures")
- ("discard", "Discard"),
- "try-post"),
-
- dl_uninstalled_deps_pre(&dl_args, "dl-uninstalled-deps-pre", '\0', "How to handle pre dependencies for uninstalled packages",
- paludis::args::EnumArg::EnumArgOptions
- ("pre", "As pre dependencies")
- ("pre-or-post", "As pre dependencies, or post depenencies where needed")
- ("post", "As post dependencies")
- ("try-post", "As post dependencies, with no error for failures")
- ("discard", "Discard"),
- "pre"),
- dl_uninstalled_deps_runtime(&dl_args, "dl-uninstalled-deps-runtime", '\0', "How to handle runtime dependencies for uninstalled packages",
- paludis::args::EnumArg::EnumArgOptions
- ("pre", "As pre dependencies")
- ("pre-or-post", "As pre dependencies, or post depenencies where needed")
- ("post", "As post dependencies")
- ("try-post", "As post dependencies, with no error for failures")
- ("discard", "Discard"),
- "pre-or-post"),
- dl_uninstalled_deps_post(&dl_args, "dl-uninstalled-deps-post", '\0', "How to handle post dependencies for uninstalled packages",
- paludis::args::EnumArg::EnumArgOptions
- ("pre", "As pre dependencies")
- ("pre-or-post", "As pre dependencies, or post depenencies where needed")
- ("post", "As post dependencies")
- ("try-post", "As post dependencies, with no error for failures")
- ("discard", "Discard"),
- "post"),
+ dl_installed_deps_pre(&dl_args, "dl-installed-deps-pre", '\0',
+ "How to handle pre dependencies for installed packages",
+ dl_deps_discard),
+ dl_installed_deps_runtime(&dl_args, "dl-installed-deps-runtime", '\0',
+ "How to handle runtime dependencies for installed packages",
+ dl_deps_try_post),
+ dl_installed_deps_post(&dl_args, "dl-installed-deps-post", '\0',
+ "How to handle post dependencies for installed packages",
+ dl_deps_try_post),
+
+ dl_uninstalled_deps_pre(&dl_args, "dl-uninstalled-deps-pre", '\0',
+ "How to handle pre dependencies for uninstalled packages",
+ dl_deps_pre),
+ dl_uninstalled_deps_runtime(&dl_args, "dl-uninstalled-deps-runtime", '\0',
+ "How to handle runtime dependencies for uninstalled packages",
+ dl_deps_pre_or_post),
+ dl_uninstalled_deps_post(&dl_args, "dl-uninstalled-deps-post", '\0',
+ "How to handle post dependencies for uninstalled packages",
+ dl_deps_post),
dl_circular(&dl_args, "dl-circular", '\0', "How to handle circular dependencies",
- paludis::args::EnumArg::EnumArgOptions
+ args::EnumArg::EnumArgOptions
("error", "Raise an error")
("discard", "Discard"),
"error"),
dl_fall_back(&dl_args, "dl-fall-back", '\0', "When to fall back to installed packages",
- paludis::args::EnumArg::EnumArgOptions
+ args::EnumArg::EnumArgOptions
("as-needed-except-targets", "Where necessary, but not for target packages")
("as-needed", "Where necessary, including for target packages")
("never", "Never"),
diff --git a/src/clients/paludis/command_line.hh b/src/clients/paludis/command_line.hh
index 6db532e..2408c0c 100644
--- a/src/clients/paludis/command_line.hh
+++ b/src/clients/paludis/command_line.hh
@@ -24,6 +24,7 @@
#include <paludis/util/instantiation_policy.hh>
#include <src/common_args/debug_build_arg.hh>
#include <src/common_args/log_level_arg.hh>
+#include <src/common_args/deps_option_arg.hh>
/** \file
* Declarations for the CommandLine class.
@@ -223,13 +224,13 @@ class CommandLine :
paludis::args::EnumArg dl_reinstall_scm;
paludis::args::EnumArg dl_upgrade;
- paludis::args::EnumArg dl_installed_deps_pre;
- paludis::args::EnumArg dl_installed_deps_runtime;
- paludis::args::EnumArg dl_installed_deps_post;
+ paludis::args::DepsOptionArg dl_installed_deps_pre;
+ paludis::args::DepsOptionArg dl_installed_deps_runtime;
+ paludis::args::DepsOptionArg dl_installed_deps_post;
- paludis::args::EnumArg dl_uninstalled_deps_pre;
- paludis::args::EnumArg dl_uninstalled_deps_runtime;
- paludis::args::EnumArg dl_uninstalled_deps_post;
+ paludis::args::DepsOptionArg dl_uninstalled_deps_pre;
+ paludis::args::DepsOptionArg dl_uninstalled_deps_runtime;
+ paludis::args::DepsOptionArg dl_uninstalled_deps_post;
paludis::args::EnumArg dl_circular;
diff --git a/src/common_args/Makefile.am b/src/common_args/Makefile.am
index 0958998..bcce723 100644
--- a/src/common_args/Makefile.am
+++ b/src/common_args/Makefile.am
@@ -11,5 +11,6 @@ noinst_LIBRARIES = libcommonargs.a
libcommonargs_a_SOURCES = \
do_help.hh \
debug_build_arg.hh debug_build_arg.cc \
+ deps_option_arg.hh deps_option_arg.cc \
log_level_arg.hh log_level_arg.cc
diff --git a/src/common_args/deps_option_arg.cc b/src/common_args/deps_option_arg.cc
new file mode 100644
index 0000000..fd8d9ff
--- /dev/null
+++ b/src/common_args/deps_option_arg.cc
@@ -0,0 +1,83 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 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 "deps_option_arg.hh"
+#include "do_help.hh"
+
+using namespace paludis;
+using namespace paludis::args;
+
+namespace
+{
+ std::string def_to_string(const DepListDepsOption d)
+ {
+ switch (d)
+ {
+ case dl_deps_discard:
+ return "discard";
+ case dl_deps_pre:
+ return "pre";
+ case dl_deps_pre_or_post:
+ return "pre-or-post";
+ case dl_deps_post:
+ return "post";
+ case dl_deps_try_post:
+ return "try-post";
+ };
+
+ throw InternalError(PALUDIS_HERE, "Unexpected DepListDepsOption value");
+ }
+}
+
+DepsOptionArg::DepsOptionArg(ArgsGroup * const grp, const std::string & ln,
+ char sh, const std::string & desc, const DepListDepsOption def) :
+ EnumArg(grp, ln, sh, desc,
+ EnumArgOptions
+ ("pre", "As pre dependencies")
+ ("pre-or-post", "As pre dependencies, or post dependencies where needed")
+ ("post", "As post dependencies")
+ ("try-post", "As post dependencies, with no error for failures")
+ ("discard", "Discard"),
+ def_to_string(def))
+{
+}
+
+DepsOptionArg::~DepsOptionArg()
+{
+}
+
+DepListDepsOption
+DepsOptionArg::option() const
+{
+ if ("pre" == argument())
+ return dl_deps_pre;
+ if ("pre-or-post" == argument())
+ return dl_deps_pre_or_post;
+ if ("post" == argument())
+ return dl_deps_post;
+ if ("try-post" == argument())
+ return dl_deps_try_post;
+ if ("discard" == argument())
+ return dl_deps_discard;
+
+ throw DoHelp("Bad value for --" + long_name());
+}
+
+
+
diff --git a/src/common_args/deps_option_arg.hh b/src/common_args/deps_option_arg.hh
new file mode 100644
index 0000000..8c2127d
--- /dev/null
+++ b/src/common_args/deps_option_arg.hh
@@ -0,0 +1,44 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 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_COMMON_ARGS_DEPS_OPTION_ARG_HH
+#define PALUDIS_GUARD_SRC_COMMON_ARGS_DEPS_OPTION_ARG_HH 1
+
+#include <paludis/args/args_option.hh>
+#include <paludis/dep_list/dep_list.hh>
+
+namespace paludis
+{
+ namespace args
+ {
+ class DepsOptionArg :
+ public EnumArg
+ {
+ public:
+ DepsOptionArg(ArgsGroup * const, const std::string &, char,
+ const std::string &, const DepListDepsOption);
+ ~DepsOptionArg();
+
+ DepListDepsOption option() const;
+ };
+
+ }
+}
+
+#endif