aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-03-31 16:44:31 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-03-31 16:44:31 +0100
commitf07f179e9bc57b1af665563f6554c55de3b8d893 (patch)
tree2b1169c870392783a4269c01de0cf8f5c642ab25
parent972f9224e48e006762892c4a35b4f0788ddadda3 (diff)
downloadpaludis-f07f179e9bc57b1af665563f6554c55de3b8d893.tar.gz
paludis-f07f179e9bc57b1af665563f6554c55de3b8d893.tar.xz
Error on conflicting options
-rw-r--r--paludis/args/args_TEST.cc4
-rw-r--r--paludis/args/args_handler.cc6
-rw-r--r--paludis/args/args_option.cc1
3 files changed, 7 insertions, 4 deletions
diff --git a/paludis/args/args_TEST.cc b/paludis/args/args_TEST.cc
index 1a2b257..bc9cf4d 100644
--- a/paludis/args/args_TEST.cc
+++ b/paludis/args/args_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2009 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2009, 2010 Ciaran McCreesh
*
* 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
@@ -94,7 +94,7 @@ CommandLine::CommandLine() :
arg_spider(&group_two, "spider", '\0', "A spider?", true),
group_three(main_options_section(), "Group three", "Description of group three"),
- arg_other_enum(&group_three, "something", '\0', "Blah.", EnumArg::EnumArgOptions("a", "A")("b", "B")("c", "C"), "b"),
+ arg_other_enum(&group_three, "something-else", '\0', "Blah.", EnumArg::EnumArgOptions("a", "A")("b", "B")("c", "C"), "b"),
arg_stringset(&group_three, "stringset", 't', "A StringSet.")
{
}
diff --git a/paludis/args/args_handler.cc b/paludis/args/args_handler.cc
index 683a9ba..1092f24 100644
--- a/paludis/args/args_handler.cc
+++ b/paludis/args/args_handler.cc
@@ -337,9 +337,13 @@ void
ArgsHandler::add_option(ArgsOption * const opt, const std::string & long_name,
const char short_name)
{
+ if (! _imp->longopts.insert(std::make_pair(long_name, opt)).second)
+ throw InternalError(PALUDIS_HERE, "duplicate long name '" + long_name + "'");
+
_imp->longopts[long_name] = opt;
if (short_name != '\0')
- _imp->shortopts[short_name] = opt;
+ if (! _imp->shortopts.insert(std::make_pair(short_name, opt)).second)
+ throw InternalError(PALUDIS_HERE, "duplicate short name '" + stringify(short_name) + "'");
}
void
diff --git a/paludis/args/args_option.cc b/paludis/args/args_option.cc
index f790863..c72cd32 100644
--- a/paludis/args/args_option.cc
+++ b/paludis/args/args_option.cc
@@ -114,7 +114,6 @@ AliasArg::AliasArg(ArgsOption * const o, const std::string & our_long_name, bool
ArgsOption(o->group(), our_long_name, '\0', "Alias for --" + o->long_name()),
_other(o), _hidden(is_hidden)
{
- o->group()->section()->handler()->add_option(o, our_long_name);
}
const std::string