aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-28 14:51:32 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-28 14:51:32 +0000
commit85aef0de194edd4bc360385c7bb2cba90267ac2d (patch)
treee983b438f05882b7ffe9ce07199ab513800f969a
parentcfa00adfbe94fdef981efa24e1075a8ac197fcad (diff)
downloadpaludis-85aef0de194edd4bc360385c7bb2cba90267ac2d.tar.gz
paludis-85aef0de194edd4bc360385c7bb2cba90267ac2d.tar.xz
Move some of the common command line argument types into their own library
-rw-r--r--Makefile.am9
-rw-r--r--src/clients/adjutrix/Makefile.am2
-rw-r--r--src/clients/adjutrix/adjutrix.cc14
-rw-r--r--src/clients/adjutrix/command_line.cc7
-rw-r--r--src/clients/adjutrix/command_line.hh3
-rw-r--r--src/clients/contrarius/Makefile.am2
-rw-r--r--src/clients/contrarius/command_line.cc7
-rw-r--r--src/clients/contrarius/command_line.hh3
-rw-r--r--src/clients/contrarius/contrarius.cc14
-rw-r--r--src/clients/paludis/Makefile.am3
-rw-r--r--src/clients/paludis/command_line.cc14
-rw-r--r--src/clients/paludis/command_line.hh19
-rw-r--r--src/clients/paludis/install.cc24
-rw-r--r--src/clients/paludis/paludis.cc70
-rw-r--r--src/clients/qualudis/Makefile.am3
-rw-r--r--src/clients/qualudis/qualudis.cc14
-rw-r--r--src/clients/qualudis/qualudis_command_line.cc7
-rw-r--r--src/clients/qualudis/qualudis_command_line.hh3
-rw-r--r--src/common_args/Makefile.am7
-rw-r--r--src/common_args/debug_build_arg.cc11
-rw-r--r--src/common_args/debug_build_arg.hh2
-rw-r--r--src/common_args/do_help.hh40
-rw-r--r--src/common_args/log_level_arg.cc57
-rw-r--r--src/common_args/log_level_arg.hh43
24 files changed, 237 insertions, 141 deletions
diff --git a/Makefile.am b/Makefile.am
index 535073d..2d41eb3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,9 +20,12 @@ automake-deps-dist-hack.tmp : built-sources-subdirs
$(MAKE) -C paludis/util
$(MAKE) -C paludis/args
$(MAKE) -C paludis/qa message-sr.hh
- $(MAKE) -C src liboutput.a
- $(MAKE) -C src/paludis paludis.1
- $(MAKE) -C src/qualudis qualudis.1
+ $(MAKE) -C src/output liboutput.a
+ $(MAKE) -C src/common_args libcommonargs.a
+ $(MAKE) -C src/clients/paludis paludis.1
+ $(MAKE) -C src/clients/qualudis qualudis.1
+ $(MAKE) -C src/clients/contrarius contrarius.1
+ $(MAKE) -C src/clients/adjutrix adjutrix.1
touch $@
dist-hook :
diff --git a/src/clients/adjutrix/Makefile.am b/src/clients/adjutrix/Makefile.am
index de550ae..e8548a2 100644
--- a/src/clients/adjutrix/Makefile.am
+++ b/src/clients/adjutrix/Makefile.am
@@ -24,6 +24,7 @@ man_adjutrix_LDADD = \
$(top_builddir)/paludis/args/libpaludisargs.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/src/output/liboutput.a \
+ $(top_builddir)/src/common_args/libcommonargs.a \
$(DYNAMIC_LD_LIBS)
adjutrix_SOURCES = \
@@ -47,6 +48,7 @@ adjutrix_LDADD = \
$(top_builddir)/paludis/dep_list/libpaludisdeplist.la \
$(top_builddir)/paludis/repositories/libpaludisrepositories.la \
$(top_builddir)/src/output/liboutput.a \
+ $(top_builddir)/src/common_args/libcommonargs.a \
$(DYNAMIC_LD_LIBS)
TESTS_ENVIRONMENT = env \
diff --git a/src/clients/adjutrix/adjutrix.cc b/src/clients/adjutrix/adjutrix.cc
index f689770..2cb3a8f 100644
--- a/src/clients/adjutrix/adjutrix.cc
+++ b/src/clients/adjutrix/adjutrix.cc
@@ -121,18 +121,10 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_version.specified())
throw DoVersion();
- if (! CommandLine::get_instance()->a_log_level.specified())
- Log::get_instance()->set_log_level(ll_qa);
- else if (CommandLine::get_instance()->a_log_level.argument() == "debug")
- Log::get_instance()->set_log_level(ll_debug);
- else if (CommandLine::get_instance()->a_log_level.argument() == "qa")
- Log::get_instance()->set_log_level(ll_qa);
- else if (CommandLine::get_instance()->a_log_level.argument() == "warning")
- Log::get_instance()->set_log_level(ll_warning);
- else if (CommandLine::get_instance()->a_log_level.argument() == "silent")
- Log::get_instance()->set_log_level(ll_silent);
+ if (CommandLine::get_instance()->a_log_level.specified())
+ Log::get_instance()->set_log_level(CommandLine::get_instance()->a_log_level.option());
else
- throw DoHelp("bad value for --log-level");
+ Log::get_instance()->set_log_level(ll_qa);
if (1 != (
CommandLine::get_instance()->a_find_stable_candidates.specified() +
diff --git a/src/clients/adjutrix/command_line.cc b/src/clients/adjutrix/command_line.cc
index 2aea616..5a4dd68 100644
--- a/src/clients/adjutrix/command_line.cc
+++ b/src/clients/adjutrix/command_line.cc
@@ -58,12 +58,7 @@ CommandLine::CommandLine() :
general_args(this, "General options",
"Options which are relevant for most or all actions."),
- a_log_level(&general_args, "log-level", '\0', "Specify the log level",
- paludis::args::EnumArg::EnumArgOptions("debug", "Show debug output (noisy)")
- ("qa", "Show QA messages and warnings only")
- ("warning", "Show warnings only")
- ("silent", "Suppress all log messages"),
- "qa"),
+ 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"),
diff --git a/src/clients/adjutrix/command_line.hh b/src/clients/adjutrix/command_line.hh
index 8efd519..4e6a0b5 100644
--- a/src/clients/adjutrix/command_line.hh
+++ b/src/clients/adjutrix/command_line.hh
@@ -22,6 +22,7 @@
#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.
@@ -79,7 +80,7 @@ class CommandLine :
/// General arguments.
paludis::args::ArgsGroup general_args;
- paludis::args::EnumArg a_log_level;
+ paludis::args::LogLevelArg a_log_level;
paludis::args::SwitchArg a_no_colour;
paludis::args::AliasArg a_no_color;
diff --git a/src/clients/contrarius/Makefile.am b/src/clients/contrarius/Makefile.am
index a5e833d..e4dc69e 100644
--- a/src/clients/contrarius/Makefile.am
+++ b/src/clients/contrarius/Makefile.am
@@ -31,6 +31,7 @@ contrarius_LDADD = \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/paludis/dep_list/libpaludisdeplist.la \
$(top_builddir)/src/output/liboutput.a \
+ $(top_builddir)/src/common_args/libcommonargs.a \
$(DYNAMIC_LD_LIBS)
contrarius_stage_options-sr.hh : contrarius_stage_options.sr $(top_srcdir)/misc/make_sr.bash
@@ -65,6 +66,7 @@ man_contrarius_LDADD = \
$(top_builddir)/paludis/args/libpaludisargs.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/src/output/liboutput.a \
+ $(top_builddir)/src/common_args/libcommonargs.a \
$(DYNAMIC_LD_LIBS)
CLEANFILES = *~ version_TEST gmon.out *.gcov *.gcno *.gcda
diff --git a/src/clients/contrarius/command_line.cc b/src/clients/contrarius/command_line.cc
index 15ed0a8..42b3a6b 100644
--- a/src/clients/contrarius/command_line.cc
+++ b/src/clients/contrarius/command_line.cc
@@ -71,12 +71,7 @@ CommandLine::CommandLine() :
output_options(this, "Options for output verbosity",
""),
a_verbose(&output_options, "verbose", 'v', "Be verbose"),
- a_log_level(&output_options, "log-level", 'L', "Specify the log level",
- paludis::args::EnumArg::EnumArgOptions("debug", "Show debug output (noisy)")
- ("qa", "Show QA messages and warnings only")
- ("warning", "Show warnings only")
- ("silent", "Suppress all log messages"),
- "warning"),
+ a_log_level(&output_options, "log-level", 'L'),
a_no_colour(&output_options, "no-colour", 'C', "Do not use colour"),
a_no_color(&a_no_colour, "no-color"),
a_resume_command_template(&output_options, "resume-command-template", '\0', "Save the resume command to a file made using mkstemp(3)")
diff --git a/src/clients/contrarius/command_line.hh b/src/clients/contrarius/command_line.hh
index 797168f..7d77700 100644
--- a/src/clients/contrarius/command_line.hh
+++ b/src/clients/contrarius/command_line.hh
@@ -6,6 +6,7 @@
#include <paludis/args/args.hh>
#include <paludis/qa/message.hh>
#include <paludis/util/instantiation_policy.hh>
+#include <src/common_args/log_level_arg.hh>
class CommandLine :
public paludis::args::ArgsHandler,
@@ -118,7 +119,7 @@ class CommandLine :
paludis::args::SwitchArg a_verbose;
/// --log-level
- paludis::args::EnumArg a_log_level;
+ paludis::args::LogLevelArg a_log_level;
/// --no-colour
paludis::args::SwitchArg a_no_colour;
diff --git a/src/clients/contrarius/contrarius.cc b/src/clients/contrarius/contrarius.cc
index ced1f3b..8d97210 100644
--- a/src/clients/contrarius/contrarius.cc
+++ b/src/clients/contrarius/contrarius.cc
@@ -53,18 +53,10 @@ int main(int argc, char *argv[])
if (CommandLine::get_instance()->a_help.specified())
throw DoHelp();
- if (! CommandLine::get_instance()->a_log_level.specified())
- Log::get_instance()->set_log_level(ll_qa);
- else if (CommandLine::get_instance()->a_log_level.argument() == "debug")
- Log::get_instance()->set_log_level(ll_debug);
- else if (CommandLine::get_instance()->a_log_level.argument() == "qa")
- Log::get_instance()->set_log_level(ll_qa);
- else if (CommandLine::get_instance()->a_log_level.argument() == "warning")
- Log::get_instance()->set_log_level(ll_warning);
- else if (CommandLine::get_instance()->a_log_level.argument() == "silent")
- Log::get_instance()->set_log_level(ll_silent);
+ if (CommandLine::get_instance()->a_log_level.specified())
+ Log::get_instance()->set_log_level(CommandLine::get_instance()->a_log_level.option());
else
- throw DoHelp("bad value for --log-level");
+ Log::get_instance()->set_log_level(ll_qa);
if (CommandLine::get_instance()->a_version.specified())
throw DoVersion();
diff --git a/src/clients/paludis/Makefile.am b/src/clients/paludis/Makefile.am
index f4fb348..ca8dd69 100644
--- a/src/clients/paludis/Makefile.am
+++ b/src/clients/paludis/Makefile.am
@@ -23,6 +23,7 @@ man_paludis_SOURCES = \
man_paludis_LDADD = \
$(top_builddir)/paludis/args/libpaludisargs.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/src/common_args/libcommonargs.a \
$(top_builddir)/src/output/liboutput.a \
$(DYNAMIC_LD_LIBS)
@@ -51,6 +52,7 @@ paludis_LDADD = \
$(top_builddir)/paludis/dep_list/libpaludisdeplist.la \
$(top_builddir)/paludis/repositories/libpaludisrepositories.la \
$(top_builddir)/src/output/liboutput.a \
+ $(top_builddir)/src/common_args/libcommonargs.a \
$(DYNAMIC_LD_LIBS)
else
@@ -63,6 +65,7 @@ paludis_LDADD = \
$(top_builddir)/paludis/environment/default/libpaludisdefaultenvironment.la \
$(top_builddir)/paludis/dep_list/libpaludisdeplist.la \
$(top_builddir)/src/output/liboutput.a \
+ $(top_builddir)/src/common_args/libcommonargs.a \
$(DYNAMIC_LD_LIBS)
endif
diff --git a/src/clients/paludis/command_line.cc b/src/clients/paludis/command_line.cc
index fb6f383..66c1d8c 100644
--- a/src/clients/paludis/command_line.cc
+++ b/src/clients/paludis/command_line.cc
@@ -61,12 +61,7 @@ CommandLine::CommandLine() :
general_args(this, "General options",
"Options which are relevant for most or all actions."),
- a_log_level(&general_args, "log-level", '\0', "Specify the log level",
- paludis::args::EnumArg::EnumArgOptions("debug", "Show debug output (noisy)")
- ("qa", "Show QA messages and warnings only")
- ("warning", "Show warnings only")
- ("silent", "Suppress all log messages"),
- "qa"),
+ 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"),
@@ -82,12 +77,7 @@ CommandLine::CommandLine() :
a_pretend(&install_args, "pretend", 'p', "Pretend only"),
a_preserve_world(&install_args, "preserve-world", '1', "Don't modify the world file"),
a_no_config_protection(&install_args, "no-config-protection", '\0', "Disable config file protection (dangerous)"),
- a_debug_build(&install_args, "debug-build", '\0', "What to do with debug information",
- paludis::args::EnumArg::EnumArgOptions
- ("none", "Discard debug information")
- ("split", "Split debug information")
- ("internal", "Keep debug information with binaries"),
- "none"),
+ 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
diff --git a/src/clients/paludis/command_line.hh b/src/clients/paludis/command_line.hh
index f2cddac..6db532e 100644
--- a/src/clients/paludis/command_line.hh
+++ b/src/clients/paludis/command_line.hh
@@ -22,6 +22,8 @@
#include <paludis/args/args.hh>
#include <paludis/util/instantiation_policy.hh>
+#include <src/common_args/debug_build_arg.hh>
+#include <src/common_args/log_level_arg.hh>
/** \file
* Declarations for the CommandLine class.
@@ -146,7 +148,7 @@ class CommandLine :
paludis::args::ArgsGroup general_args;
/// --log-level
- paludis::args::EnumArg a_log_level;
+ paludis::args::LogLevelArg a_log_level;
/// --no-colour
paludis::args::SwitchArg a_no_colour;
@@ -192,7 +194,7 @@ class CommandLine :
paludis::args::SwitchArg a_no_config_protection;
/// --debug-build
- paludis::args::EnumArg a_debug_build;
+ paludis::args::DebugBuildArg a_debug_build;
/// --fetch
paludis::args::SwitchArg a_fetch;
@@ -276,17 +278,4 @@ class CommandLine :
paludis::args::SwitchArg a_dl_ignore_installed;
};
-/**
- * Show the help message.
- */
-struct DoHelp
-{
- const std::string message;
-
- DoHelp(const std::string & m = "") :
- message(m)
- {
- }
-};
-
#endif
diff --git a/src/clients/paludis/install.cc b/src/clients/paludis/install.cc
index 52dcb98..4ab4d53 100644
--- a/src/clients/paludis/install.cc
+++ b/src/clients/paludis/install.cc
@@ -21,6 +21,7 @@
#include "install.hh"
#include <src/output/licence.hh>
#include <src/output/console_install_task.hh>
+#include <src/common_args/do_help.hh>
#include <iostream>
#include <limits>
@@ -197,7 +198,7 @@ namespace
else if (arg.argument() == "discard")
return dl_deps_discard;
else
- throw DoHelp("bad value for --" + arg.long_name());
+ throw args::DoHelp("bad value for --" + arg.long_name());
}
}
@@ -219,7 +220,7 @@ do_install()
else if (CommandLine::get_instance()->dl_reinstall.argument() == "if-use-changed")
options.reinstall = dl_reinstall_if_use_changed;
else
- throw DoHelp("bad value for --dl-reinstall");
+ throw args::DoHelp("bad value for --dl-reinstall");
}
if (CommandLine::get_instance()->dl_reinstall_scm.specified())
@@ -233,7 +234,7 @@ do_install()
else if (CommandLine::get_instance()->dl_reinstall_scm.argument() == "weekly")
options.reinstall_scm = dl_reinstall_scm_weekly;
else
- throw DoHelp("bad value for --dl-reinstall-scm");
+ throw args::DoHelp("bad value for --dl-reinstall-scm");
}
if (CommandLine::get_instance()->dl_upgrade.specified())
@@ -243,7 +244,7 @@ do_install()
else if (CommandLine::get_instance()->dl_upgrade.argument() == "always")
options.upgrade = dl_upgrade_always;
else
- throw DoHelp("bad value for --dl-upgrade");
+ throw args::DoHelp("bad value for --dl-upgrade");
}
if (CommandLine::get_instance()->dl_circular.specified())
@@ -253,7 +254,7 @@ do_install()
else if (CommandLine::get_instance()->dl_circular.argument() == "error")
options.circular = dl_circular_error;
else
- throw DoHelp("bad value for --dl-circular");
+ throw args::DoHelp("bad value for --dl-circular");
}
if (CommandLine::get_instance()->dl_fall_back.specified())
@@ -265,7 +266,7 @@ do_install()
else if (CommandLine::get_instance()->dl_fall_back.argument() == "never")
options.fall_back = dl_fall_back_never;
else
- throw DoHelp("bad value for --dl-fall-back");
+ throw args::DoHelp("bad value for --dl-fall-back");
}
if (CommandLine::get_instance()->dl_installed_deps_pre.specified())
@@ -299,16 +300,7 @@ do_install()
task.set_preserve_world(CommandLine::get_instance()->a_preserve_world.specified());
if (CommandLine::get_instance()->a_debug_build.specified())
- {
- if (CommandLine::get_instance()->a_debug_build.argument() == "none")
- task.set_debug_mode(ido_none);
- else if (CommandLine::get_instance()->a_debug_build.argument() == "split")
- task.set_debug_mode(ido_split);
- else if (CommandLine::get_instance()->a_debug_build.argument() == "internal")
- task.set_debug_mode(ido_internal);
- else
- throw DoHelp("bad value for --debug-build");
- }
+ task.set_debug_mode(CommandLine::get_instance()->a_debug_build.option());
InstallKilledCatcher install_killed_catcher(task);
diff --git a/src/clients/paludis/paludis.cc b/src/clients/paludis/paludis.cc
index 93da1e8..ca38388 100644
--- a/src/clients/paludis/paludis.cc
+++ b/src/clients/paludis/paludis.cc
@@ -18,8 +18,8 @@
*/
#include "applets.hh"
-#include <src/output/colour.hh>
#include "command_line.hh"
+#include "config.h"
#include "do_contents.hh"
#include "install.hh"
#include "list.hh"
@@ -29,7 +29,9 @@
#include "report.hh"
#include "sync.hh"
#include "uninstall.hh"
-#include "config.h"
+
+#include <src/common_args/do_help.hh>
+#include <src/output/colour.hh>
#include <paludis/paludis.hh>
#include <paludis/hashed_containers.hh>
@@ -141,23 +143,15 @@ main(int argc, char *argv[])
set_use_colour(! CommandLine::get_instance()->a_no_color.specified());
if (CommandLine::get_instance()->a_help.specified())
- throw DoHelp();
+ 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(ll_qa);
- else if (CommandLine::get_instance()->a_log_level.argument() == "debug")
- Log::get_instance()->set_log_level(ll_debug);
- else if (CommandLine::get_instance()->a_log_level.argument() == "qa")
- Log::get_instance()->set_log_level(ll_qa);
- else if (CommandLine::get_instance()->a_log_level.argument() == "warning")
- Log::get_instance()->set_log_level(ll_warning);
- else if (CommandLine::get_instance()->a_log_level.argument() == "silent")
- Log::get_instance()->set_log_level(ll_silent);
+ if (CommandLine::get_instance()->a_log_level.specified())
+ Log::get_instance()->set_log_level(CommandLine::get_instance()->a_log_level.option());
else
- throw DoHelp("bad value for --log-level");
+ Log::get_instance()->set_log_level(ll_qa);
Log::get_instance()->set_program_name(argv[0]);
@@ -241,10 +235,10 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
else
- throw DoHelp("don't be silly");
+ throw args::DoHelp("don't be silly");
}
else
- throw DoHelp("you should specify exactly one action");
+ throw args::DoHelp("you should specify exactly one action");
}
/* these actions don't need DefaultConfig */
@@ -252,7 +246,7 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_list_sync_protocols.specified())
{
if (! CommandLine::get_instance()->empty())
- throw DoHelp("list-sync-protocols action takes no parameters");
+ throw args::DoHelp("list-sync-protocols action takes no parameters");
return do_list_sync_protocols();
}
@@ -260,7 +254,7 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_list_repository_formats.specified())
{
if (! CommandLine::get_instance()->empty())
- throw DoHelp("list-repository-formats action takes no parameters");
+ throw args::DoHelp("list-repository-formats action takes no parameters");
return do_list_repository_formats();
}
@@ -268,7 +262,7 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_list_dep_tag_categories.specified())
{
if (! CommandLine::get_instance()->empty())
- throw DoHelp("list-dep-tag-categories action takes no parameters");
+ throw args::DoHelp("list-dep-tag-categories action takes no parameters");
return do_list_dep_tag_categories();
}
@@ -303,7 +297,7 @@ main(int argc, char *argv[])
// The template should contain at least XXXXXX
std::string resume_template = CommandLine::get_instance()->a_resume_command_template.argument();
if (resume_template.find("XXXXXX", 0) == std::string::npos )
- throw DoHelp("resume-command-template must contain at least XXXXXX");
+ throw args::DoHelp("resume-command-template must contain at least XXXXXX");
}
if (CommandLine::get_instance()->a_info.specified())
@@ -318,7 +312,7 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_query.specified())
{
if (CommandLine::get_instance()->empty())
- throw DoHelp("query action requires at least one parameter");
+ throw args::DoHelp("query action requires at least one parameter");
return do_query();
}
@@ -326,7 +320,7 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_install.specified())
{
if (CommandLine::get_instance()->empty())
- throw DoHelp("install action requires at least one parameter");
+ throw args::DoHelp("install action requires at least one parameter");
return do_install();
}
@@ -334,7 +328,7 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_uninstall.specified())
{
if (CommandLine::get_instance()->empty())
- throw DoHelp("uninstall action requires at least one parameter");
+ throw args::DoHelp("uninstall action requires at least one parameter");
return do_uninstall();
}
@@ -342,7 +336,7 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_uninstall_unused.specified())
{
if (! CommandLine::get_instance()->empty())
- throw DoHelp("uninstall-unused action takes no parameters");
+ throw args::DoHelp("uninstall-unused action takes no parameters");
return do_uninstall_unused();
}
@@ -355,14 +349,14 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_report.specified())
{
if (! CommandLine::get_instance()->empty())
- throw DoHelp("report action takes no parameters");
+ throw args::DoHelp("report action takes no parameters");
return do_report();
}
if (CommandLine::get_instance()->a_list_repositories.specified())
{
if (! CommandLine::get_instance()->empty())
- throw DoHelp("list-repositories action takes no parameters");
+ throw args::DoHelp("list-repositories action takes no parameters");
return do_list_repositories();
}
@@ -370,7 +364,7 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_list_categories.specified())
{
if (! CommandLine::get_instance()->empty())
- throw DoHelp("list-categories action takes no parameters");
+ throw args::DoHelp("list-categories action takes no parameters");
return do_list_categories();
}
@@ -378,7 +372,7 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_list_packages.specified())
{
if (! CommandLine::get_instance()->empty())
- throw DoHelp("list-packages action takes no parameters");
+ throw args::DoHelp("list-packages action takes no parameters");
return do_list_packages();
}
@@ -386,7 +380,7 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_list_sets.specified())
{
if (! CommandLine::get_instance()->empty())
- throw DoHelp("list-sets action takes no parameters");
+ throw args::DoHelp("list-sets action takes no parameters");
return do_list_sets();
}
@@ -394,7 +388,7 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_contents.specified())
{
if (CommandLine::get_instance()->empty())
- throw DoHelp("contents action requires at least one parameter");
+ throw args::DoHelp("contents action requires at least one parameter");
return do_contents();
}
@@ -402,7 +396,7 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_owner.specified())
{
if (CommandLine::get_instance()->empty())
- throw DoHelp("owner action requires at least one parameter");
+ throw args::DoHelp("owner action requires at least one parameter");
return do_owner();
}
@@ -411,7 +405,7 @@ main(int argc, char *argv[])
{
if (1 != std::distance(CommandLine::get_instance()->begin_parameters(),
CommandLine::get_instance()->end_parameters()))
- throw DoHelp("has-version action takes exactly one parameter");
+ throw args::DoHelp("has-version action takes exactly one parameter");
return do_has_version();
}
@@ -420,7 +414,7 @@ main(int argc, char *argv[])
{
if (1 != std::distance(CommandLine::get_instance()->begin_parameters(),
CommandLine::get_instance()->end_parameters()))
- throw DoHelp("best-version action takes exactly one parameter");
+ throw args::DoHelp("best-version action takes exactly one parameter");
return do_best_version();
}
@@ -429,7 +423,7 @@ main(int argc, char *argv[])
{
if (2 != std::distance(CommandLine::get_instance()->begin_parameters(),
CommandLine::get_instance()->end_parameters()))
- throw DoHelp("environment-variable action takes exactly two parameters (depatom var)");
+ throw args::DoHelp("environment-variable action takes exactly two parameters (depatom var)");
return do_environment_variable();
}
@@ -438,7 +432,7 @@ main(int argc, char *argv[])
{
if (2 != std::distance(CommandLine::get_instance()->begin_parameters(),
CommandLine::get_instance()->end_parameters()))
- throw DoHelp("configuration-variable action takes exactly two parameters (repository var)");
+ throw args::DoHelp("configuration-variable action takes exactly two parameters (repository var)");
return do_configuration_variable();
}
@@ -446,7 +440,7 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_update_news.specified())
{
if (! CommandLine::get_instance()->empty())
- throw DoHelp("update-news action takes no parameters");
+ throw args::DoHelp("update-news action takes no parameters");
return do_update_news();
}
@@ -455,7 +449,7 @@ main(int argc, char *argv[])
CommandLine::get_instance()->a_regenerate_installable_cache.specified())
{
if (! CommandLine::get_instance()->empty())
- throw DoHelp("regenerate cache actions takes no parameters");
+ throw args::DoHelp("regenerate cache actions takes no parameters");
return do_regenerate_cache(CommandLine::get_instance()->a_regenerate_installed_cache.specified());
}
@@ -478,7 +472,7 @@ main(int argc, char *argv[])
cerr << "Try " << argv[0] << " --help" << endl;
return EXIT_FAILURE;
}
- catch (const DoHelp & h)
+ catch (const args::DoHelp & h)
{
if (h.message.empty())
{
diff --git a/src/clients/qualudis/Makefile.am b/src/clients/qualudis/Makefile.am
index 8e9225b..361ec04 100644
--- a/src/clients/qualudis/Makefile.am
+++ b/src/clients/qualudis/Makefile.am
@@ -28,6 +28,7 @@ qualudis_LDADD = \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/libxml/libpaludislibxml.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/src/common_args/libcommonargs.a \
$(PCREPLUSPLUS_LIBS) \
$(LIBXML2DEPS_LIBS) \
$(DYNAMIC_LD_LIBS)
@@ -40,6 +41,7 @@ qualudis_LDADD = \
$(top_builddir)/paludis/args/libpaludisargs.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/src/output/liboutput.a \
+ $(top_builddir)/src/common_args/libcommonargs.a \
$(PCREPLUSPLUS_LIBS) \
$(LIBXML2DEPS_LIBS) \
$(DYNAMIC_LD_LIBS)
@@ -73,6 +75,7 @@ man_qualudis_LDADD = \
$(top_builddir)/paludis/args/libpaludisargs.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/src/output/liboutput.a \
+ $(top_builddir)/src/common_args/libcommonargs.a \
$(DYNAMIC_LD_LIBS)
CLEANFILES = *~ version_TEST gmon.out *.gcov *.gcno *.gcda
diff --git a/src/clients/qualudis/qualudis.cc b/src/clients/qualudis/qualudis.cc
index 50963f2..79d8541 100644
--- a/src/clients/qualudis/qualudis.cc
+++ b/src/clients/qualudis/qualudis.cc
@@ -504,18 +504,10 @@ int main(int argc, char *argv[])
if (QualudisCommandLine::get_instance()->a_help.specified())
throw DoHelp();
- if (! QualudisCommandLine::get_instance()->a_log_level.specified())
- Log::get_instance()->set_log_level(ll_qa);
- else if (QualudisCommandLine::get_instance()->a_log_level.argument() == "debug")
- Log::get_instance()->set_log_level(ll_debug);
- else if (QualudisCommandLine::get_instance()->a_log_level.argument() == "qa")
- Log::get_instance()->set_log_level(ll_qa);
- else if (QualudisCommandLine::get_instance()->a_log_level.argument() == "warning")
- Log::get_instance()->set_log_level(ll_warning);
- else if (QualudisCommandLine::get_instance()->a_log_level.argument() == "silent")
- Log::get_instance()->set_log_level(ll_silent);
+ if (QualudisCommandLine::get_instance()->a_log_level.specified())
+ Log::get_instance()->set_log_level(QualudisCommandLine::get_instance()->a_log_level.option());
else
- throw DoHelp("bad value for --log-level");
+ Log::get_instance()->set_log_level(ll_qa);
if (! QualudisCommandLine::get_instance()->a_message_level.specified())
QualudisCommandLine::get_instance()->message_level = qa::qal_info;
diff --git a/src/clients/qualudis/qualudis_command_line.cc b/src/clients/qualudis/qualudis_command_line.cc
index 99f50e1..d02561d 100644
--- a/src/clients/qualudis/qualudis_command_line.cc
+++ b/src/clients/qualudis/qualudis_command_line.cc
@@ -36,12 +36,7 @@ QualudisCommandLine::QualudisCommandLine() :
a_qa_checks(&check_options, "qa-check", 'c', "Only perform given check."),
a_verbose(&check_options, "verbose", 'v', "Be verbose"),
a_quiet(&check_options, "quiet", 'q', "Be quiet"),
- a_log_level(&check_options, "log-level", 'L', "Specify the log level",
- paludis::args::EnumArg::EnumArgOptions("debug", "Show debug output (noisy)")
- ("qa", "Show QA messages and warnings only")
- ("warning", "Show warnings only")
- ("silent", "Suppress all log messages"),
- "warning"),
+ a_log_level(&check_options, "log-level", 'L'),
a_message_level(&check_options, "message-level", 'M', "Specify the message level",
paludis::args::EnumArg::EnumArgOptions("info", "Show info and upwards")
diff --git a/src/clients/qualudis/qualudis_command_line.hh b/src/clients/qualudis/qualudis_command_line.hh
index 630f8ca..008997c 100644
--- a/src/clients/qualudis/qualudis_command_line.hh
+++ b/src/clients/qualudis/qualudis_command_line.hh
@@ -6,6 +6,7 @@
#include <paludis/args/args.hh>
#include <paludis/qa/message.hh>
#include <paludis/util/instantiation_policy.hh>
+#include <src/common_args/log_level_arg.hh>
class QualudisCommandLine :
public paludis::args::ArgsHandler,
@@ -63,7 +64,7 @@ class QualudisCommandLine :
paludis::args::SwitchArg a_quiet;
/// --log-level
- paludis::args::EnumArg a_log_level;
+ paludis::args::LogLevelArg a_log_level;
/// --message-level
paludis::args::EnumArg a_message_level;
diff --git a/src/common_args/Makefile.am b/src/common_args/Makefile.am
index 03e2bc4..0958998 100644
--- a/src/common_args/Makefile.am
+++ b/src/common_args/Makefile.am
@@ -6,3 +6,10 @@ AM_CXXFLAGS = -I$(top_srcdir) -I$(top_srcdir)/src @PALUDIS_CXXFLAGS@
built-sources : $(BUILT_SOURCES)
for s in `echo $(SUBDIRS) | tr -d .` ; do $(MAKE) -C $$s built-sources || exit 1 ; done
+noinst_LIBRARIES = libcommonargs.a
+
+libcommonargs_a_SOURCES = \
+ do_help.hh \
+ debug_build_arg.hh debug_build_arg.cc \
+ log_level_arg.hh log_level_arg.cc
+
diff --git a/src/common_args/debug_build_arg.cc b/src/common_args/debug_build_arg.cc
index 621a71b..d649d41 100644
--- a/src/common_args/debug_build_arg.cc
+++ b/src/common_args/debug_build_arg.cc
@@ -18,12 +18,19 @@
*/
#include "debug_build_arg.hh"
+#include "do_help.hh"
using namespace paludis;
using namespace paludis::args;
-DebugBuildArg::DebugBuildArg() :
- EnumArg()
+DebugBuildArg::DebugBuildArg(ArgsGroup * const grp, const std::string & ln,
+ char sh) :
+ EnumArg(grp, ln, sh, "What to do with debug information",
+ EnumArgOptions
+ ("none", "Discard debug information")
+ ("split", "Split debug information")
+ ("internal", "Keep debug information"),
+ "none")
{
}
diff --git a/src/common_args/debug_build_arg.hh b/src/common_args/debug_build_arg.hh
index 1947bbf..10fa9b6 100644
--- a/src/common_args/debug_build_arg.hh
+++ b/src/common_args/debug_build_arg.hh
@@ -31,7 +31,7 @@ namespace paludis
public EnumArg
{
public:
- DebugBuildArg();
+ DebugBuildArg(ArgsGroup * const, const std::string &, char);
~DebugBuildArg();
InstallDebugOption option() const;
diff --git a/src/common_args/do_help.hh b/src/common_args/do_help.hh
new file mode 100644
index 0000000..ff38e69
--- /dev/null
+++ b/src/common_args/do_help.hh
@@ -0,0 +1,40 @@
+/* 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_DO_HELP_HH
+#define PALUDIS_GUARD_SRC_COMMON_ARGS_DO_HELP_HH 1
+
+namespace paludis
+{
+ namespace args
+ {
+ struct DoHelp
+ {
+ const std::string message;
+
+ DoHelp(const std::string & m = "") :
+ message(m)
+ {
+ }
+ };
+ }
+}
+
+
+#endif
diff --git a/src/common_args/log_level_arg.cc b/src/common_args/log_level_arg.cc
new file mode 100644
index 0000000..441db39
--- /dev/null
+++ b/src/common_args/log_level_arg.cc
@@ -0,0 +1,57 @@
+/* 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 "log_level_arg.hh"
+#include "do_help.hh"
+
+using namespace paludis;
+using namespace paludis::args;
+
+LogLevelArg::LogLevelArg(ArgsGroup * const grp, const std::string & ln,
+ char sh) :
+ EnumArg(grp, ln, sh, "Specify the log level",
+ EnumArgOptions
+ ("debug", "Show debug output (noisy)")
+ ("qa", "Show QA messages and warnings only")
+ ("warning", "Show warnings only")
+ ("silent", "Suppress all log messages (UNSAFE)"),
+ "qa")
+{
+}
+
+LogLevelArg::~LogLevelArg()
+{
+}
+
+LogLevel
+LogLevelArg::option() const
+{
+ if ("debug" == argument())
+ return ll_debug;
+ if ("qa" == argument())
+ return ll_qa;
+ if ("warning" == argument())
+ return ll_warning;
+ if ("silent" == argument())
+ return ll_silent;
+
+ throw DoHelp("Bad value for --" + long_name());
+}
+
+
diff --git a/src/common_args/log_level_arg.hh b/src/common_args/log_level_arg.hh
new file mode 100644
index 0000000..f60e866
--- /dev/null
+++ b/src/common_args/log_level_arg.hh
@@ -0,0 +1,43 @@
+/* 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_LOG_LEVEL_ARG_HH
+#define PALUDIS_GUARD_SRC_COMMON_ARGS_LOG_LEVEL_ARG_HH 1
+
+#include <paludis/args/args_option.hh>
+#include <paludis/util/log.hh>
+
+namespace paludis
+{
+ namespace args
+ {
+ class LogLevelArg :
+ public EnumArg
+ {
+ public:
+ LogLevelArg(ArgsGroup * const, const std::string &, char);
+ ~LogLevelArg();
+
+ LogLevel option() const;
+ };
+
+ }
+}
+
+#endif