c++c++11command-line-arguments

Using the Argo Command line parser: Unknown option is not returned when option is behind a exsiting option


Using this very nice Commandline parser Argo (Header only C++ library) I've encountered a small issue. See : https://github.com/phforest/Argo

Argo returns : 'Error: Unknown option' when a option in not found, but not when the argument is behind a know argument.

Compiling the code below: (inc is location of the argo header) c++ test.cpp -I inc --std=c++11

#include <iostream>
int main(int argc, char **argv)
{
        argo::Configuration pcnfg;
        std::vector<std::string>    input_texts;
        pcnfg.program.name = { "wow", "EyeOnText WoWoolConsole" };
        pcnfg.program.version = { 1, 1, 1 };

        argo::Arguments args(pcnfg);
        args.add(argo::handler::Option("input-text", "i", input_texts).help("Input text to process."));

        const auto result = args.parse(argc, argv);
        switch (result.status)
        {
            case argo::ReturnCode::Error: std::cerr << "Error: " << result.message << std::endl; return 1;
            case argo::ReturnCode::SuccessAndAbort: return 0;
            default: break;
        }

        for ( auto const & input : input_texts )
        {
            std::cout << "- " << input << std::endl;
        }
    return 0;
}

run: ./a.out --other -i "test" Error: Unknown option '--other' Which is ok

run: ./a.out -i "test" --other - test - --other

--other should not be in the input list.


Solution

  • (Disclaimer: I'm the developer of the library)

    I think this is solved in more recent versions. At least, using the provided code, I get the expected output (twice an 'Unknown option' error). If it's not solved, we can take it up using the bug tracker at https://gitlab.com/dgrine/Argo/issues