Skip to content

Error message is misleading when a required option is missing #105

@yeetfield

Description

@yeetfield

This applies to version 1.7 and was not occurring in 1.6.1. The following program

#include <lyra/lyra.hpp>

#include <iostream>
#include <string>

int main(int argc, const char *argv[]) {
  std::string a;
  std::string b;
  lyra::cli cli = lyra::opt(a, "A")["-a"]["--a-flag"]("The A flag").required()
                  | lyra::opt(b, "B")["-b"]["--b-flag"]("The B flag").required();
  auto result = cli.parse({argc, argv});
  if (!result) {
    std::cerr << "Error in command line: " << result.message() << std::endl;
  }
}

when run as main -a ayy (i.e. omitting the required --b-flag) prints Error in command line: Unrecognized argument '-a' while parsing: -b|--b-flag <B>, when previously it would've printed Error in command line: Expected: -b|--b-flag <B>.

Metadata

Metadata

Assignees

No one assigned

    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