summaryrefslogtreecommitdiff
path: root/src/commands.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-03-29 19:34:57 +0100
committerMaxime Coste <frrrwww@gmail.com>2013-03-31 14:53:32 +0200
commitf09e24607aa2a5bebbc5b416e4dc4a1aafda6965 (patch)
tree37daa4f60ab2863096f6f558c798d48eb5a53774 /src/commands.cc
parenta80cee0d2c1b18e2de5c90442812a325f151532a (diff)
add support for adding to options instead of replacing
Diffstat (limited to 'src/commands.cc')
-rw-r--r--src/commands.cc28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/commands.cc b/src/commands.cc
index b9ebd3b4..3043fbd8 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -437,31 +437,39 @@ void exec_commands_in_file(const CommandParameters& params,
void set_global_option(const CommandParameters& params, Context& context)
{
- if (params.size() != 2)
- throw wrong_argument_count();
+ ParametersParser parser(params, { { "add", false } }, 2, 2);
- GlobalOptions::instance().get_local_option(params[0]).set_from_string(params[1]);
+ Option& opt = GlobalOptions::instance().get_local_option(parser[0]);
+ if (parser.has_option("add"))
+ opt.add_from_string(parser[1]);
+ else
+ opt.set_from_string(parser[1]);
}
void set_buffer_option(const CommandParameters& params, Context& context)
{
- ParametersParser parser(params, { { "buffer", true } });
- if (parser.positional_count() != 2)
- throw wrong_argument_count();
+ ParametersParser parser(params, { { "buffer", true }, { "add", false } }, 2, 2);
OptionManager& options = parser.has_option("buffer") ?
BufferManager::instance().get_buffer(parser.option_value("buffer")).options()
: context.buffer().options();
- options.get_local_option(parser[0]).set_from_string(parser[1]);
+ Option& opt = options.get_local_option(parser[0]);
+ if (parser.has_option("add"))
+ opt.add_from_string(parser[1]);
+ else
+ opt.set_from_string(parser[1]);
}
void set_window_option(const CommandParameters& params, Context& context)
{
- if (params.size() != 2)
- throw wrong_argument_count();
+ ParametersParser parser(params, { { "add", false } }, 2, 2);
- context.window().options().get_local_option(params[0]).set_from_string(params[1]);
+ Option& opt = context.window().options().get_local_option(parser[0]);
+ if (parser.has_option("add"))
+ opt.add_from_string(parser[1]);
+ else
+ opt.set_from_string(parser[1]);
}
void declare_option(const CommandParameters& params, Context& context)