summaryrefslogtreecommitdiff
path: root/src/option_types.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-05-30 23:23:38 +1000
committerMaxime Coste <mawww@kakoune.org>2018-07-05 07:54:28 +1000
commitb548dd3a6f369e5a244fdcdca55061513026f82a (patch)
tree1ca672c1d6f976a74f34d37f75fd68a83933fbe1 /src/option_types.cc
parent5eeec8bd4d24882ea443c4441f696257b8cb68c4 (diff)
Change option lists to be specified as separate arguments on commands line
Option lists and maps are specified using separate arguments, avoiding the need for additional escaping of their separator and reusing the existing command line spliting logic instead. As discussed on #2087, this should make it much easier to work with list options, and make the general option system feel cleaner.
Diffstat (limited to 'src/option_types.cc')
-rw-r--r--src/option_types.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/option_types.cc b/src/option_types.cc
index f32e361f..5cd4371c 100644
--- a/src/option_types.cc
+++ b/src/option_types.cc
@@ -5,19 +5,20 @@ namespace Kakoune
{
UnitTest test_option_parsing{[]{
- auto check = [](auto&& value, StringView str)
+ auto check = [](auto&& value, ConstArrayView<String> strs)
{
- auto repr = option_to_string(value);
- kak_assert(repr == str);
- auto parsed = option_from_string(Meta::Type<std::decay_t<decltype(value)>>{}, str);
+ auto repr = option_to_strings(value);
+ kak_assert(strs == ConstArrayView<String>{repr});
+ auto parsed = option_from_strings(Meta::Type<std::decay_t<decltype(value)>>{}, strs);
kak_assert(parsed == value);
};
- check(123, "123");
- check(true, "true");
- check(Vector<String>{"foo", "bar:", "baz"}, "foo:bar\\::baz");
- check(HashMap<String, int>{{"foo", 10}, {"b=r", 20}, {"b:z", 30}}, "foo=10:b\\=r=20:b\\:z=30");
- check(DebugFlags::Keys | DebugFlags::Hooks, "hooks|keys");
+ check(123, {"123"});
+ check(true, {"true"});
+ check(Vector<String>{"foo", "bar:", "baz"}, {"foo", "bar:", "baz"});
+ check(Vector<int>{10, 20, 30}, {"10", "20", "30"});
+ check(HashMap<String, int>{{"foo", 10}, {"b=r", 20}, {"b:z", 30}}, {"foo=10", "b\\=r=20", "b:z=30"});
+ check(DebugFlags::Keys | DebugFlags::Hooks, {"hooks|keys"});
}};
}