Repository: CLIUtils/CLI11 (C++)

Issue:
Config file parsing breaks on multi-line arrays with no element on the first line
Using the v2.5.0 mono-header from releases.

main.cpp:

```c++
#include <vector>

#include "CLI11.hpp"

int main(int argc, char** argv) {
    CLI::App app;
    argv = app.ensure_utf8(argv);

    std::vector<int> test;
    app.add_option("--test", test);
    
    app.set_config("--config");

    CLI11_PARSE(app, argc, argv);
    return 0;
}
```

config.toml

```toml
test = [
1,2,3]
```

Run as:

```bash
$ g++ main.cpp 
$ ./a.out --config config.toml
Could not convert: --test = [
Run with --help for more information.
$
```

---

I encountered this importing a TOML generated by [Toml++](https://github.com/marzer/tomlplusplus), which unconditionally wraps long arrays as:

```toml
array = [
    'item1',
    'item2',
    'item3',
    'item4'
]
```

(indent optional)

Given that this is valid TOML, CLI11 should be able to parse it.

#528 originally implemented multi-line array support, but missed this case


Discussion:
I will look into it



Patch:
diff --git a/include/CLI/impl/Config_inl.hpp b/include/CLI/impl/Config_inl.hpp
index 0a2cc4259..19bb15874 100644
--- a/include/CLI/impl/Config_inl.hpp
+++ b/include/CLI/impl/Config_inl.hpp
@@ -414,7 +414,7 @@ inline std::vector<ConfigItem> ConfigBase::from_config(std::istream &input) cons
                     }
                 }
                 items_buffer = {item};
-            } else if(item.size() > 1 && item.front() == aStart) {
+            } else if(!item.empty() && item.front() == aStart) {
                 for(std::string multiline; item.back() != aEnd && std::getline(input, multiline);) {
                     detail::trim(multiline);
                     item += multiline;


Test patch:
diff --git a/tests/ConfigFileTest.cpp b/tests/ConfigFileTest.cpp
index 53368e9ee..634890d77 100644
--- a/tests/ConfigFileTest.cpp
+++ b/tests/ConfigFileTest.cpp
@@ -1510,6 +1510,57 @@ TEST_CASE_METHOD(TApp, "TOMLVector", "[config]") {
     CHECK(three == std::vector<int>({1, 2, 3}));
 }
 
+TEST_CASE_METHOD(TApp, "TOMLMultiLineVector", "[config]") {
+
+    TempFile tmptoml{"TestTomlTmp.toml"};
+
+    app.set_config("--config", tmptoml);
+
+    {
+        std::ofstream out{tmptoml};
+        out << "#this is a comment line\n";
+        out << "[default]\n";
+        out << "two=[\n";
+        out << "  2, 3\n";
+        out << "]\n";
+        out << "three=[\n\t1,\n\t2,\n\t3\n]\n";
+    }
+
+    std::vector<int> two, three;
+    app.add_option("--two", two)->expected(2)->required();
+    app.add_option("--three", three)->required();
+
+    run();
+
+    CHECK(two == std::vector<int>({2, 3}));
+    CHECK(three == std::vector<int>({1, 2, 3}));
+}
+
+TEST_CASE_METHOD(TApp, "TOMLMultiLineVector2", "[config]") {
+
+    TempFile tmptoml{"TestTomlTmp.toml"};
+
+    app.set_config("--config", tmptoml);
+
+    {
+        std::ofstream out{tmptoml};
+        out << "#this is a comment line\n";
+        out << "[default]\n";
+        out << "two=[\n";
+        out << "  2, 3]\n";
+        out << "three=[\n\t1,\n\t2,\n\t3\n]\n";
+    }
+
+    std::vector<int> two, three;
+    app.add_option("--two", two)->expected(2)->required();
+    app.add_option("--three", three)->required();
+
+    run();
+
+    CHECK(two == std::vector<int>({2, 3}));
+    CHECK(three == std::vector<int>({1, 2, 3}));
+}
+
 TEST_CASE_METHOD(TApp, "ColonValueSep", "[config]") {
 
     TempFile tmpini{"TestIniTmp.ini"};
@@ -1700,6 +1751,30 @@ TEST_CASE_METHOD(TApp, "TOMLStringVector", "[config]") {
     CHECK(three == std::vector<std::string>({"1", "2", "3"}));
 }
 
+TEST_CASE_METHOD(TApp, "TOMLStringVectorMultiline", "[config]") {
+
+    TempFile tmptoml{"TestTomlTmp.toml"};
+
+    app.set_config("--config", tmptoml);
+
+    {
+        std::ofstream out{tmptoml};
+        out << "#this is a comment line\n";
+        out << "[default]\n";
+        out << "two=[\n\t\t\"2\",\"3\"]\n";
+        out << "three=[\n    \"1\",\n    \"2\",\n    \"3\"\n]    \n";
+    }
+
+    std::vector<std::string> two, three;
+
+    app.add_option("--two", two)->required();
+    app.add_option("--three", three)->required();
+
+    run();
+    CHECK(two == std::vector<std::string>({"2", "3"}));
+    CHECK(three == std::vector<std::string>({"1", "2", "3"}));
+}
+
 TEST_CASE_METHOD(TApp, "IniVectorCsep", "[config]") {
 
     TempFile tmpini{"TestIniTmp.ini"};