Skip to content

Config file parsing breaks on multi-line arrays with no element on the first line #1195

@beta382

Description

@beta382

Using the v2.5.0 mono-header from releases.

main.cpp:

#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

test = [
1,2,3]

Run as:

$ 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++, which unconditionally wraps long arrays as:

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions