bfgroup / Lyra

A simple to use, composable, command line parser for C++ 11 and beyond
https://bfgroup.github.io/Lyra/
Boost Software License 1.0
483 stars 58 forks source link

Named args with parameters' args don't appear in usage #35

Closed mattgodbolt closed 4 years ago

mattgodbolt commented 4 years ago

In the config:

#include <lyra/lyra.hpp>
#include <string>

int main(int argc, const char *argv[]) {
  std::string named_required;
  std::string optional;
  auto cli = lyra::opt(named_required,
                  "required-arg")["--required"]("You must supply this arg")
            .required() |
        lyra::arg(optional, "optional")("This is an optional arg");

    std::cout << cli << "\n";
}

The output is:

USAGE:
  <executable> --required [<optional>]

OPTIONS, ARGUMENTS:
  --required <required-arg>
                          You must supply this arg
  <optional>              This is an optional arg

The --required in the USAGE: line does not refer to the required parameter name. I'd expect to see:

USAGE:
  <executable> --required <required-arg> [<optional>]

OPTIONS, ARGUMENTS:
  --required <required-arg>
                          You must supply this arg
  <optional>              This is an optional arg
grafikrobot commented 4 years ago

WOW... That bug has been there for over a year. Since the initial refactor from Clara. Will fix ASAP.

grafikrobot commented 4 years ago

FYI.. https://github.com/bfgroup/Lyra/releases/tag/1.5.1

mattgodbolt commented 4 years ago

Wow! thanks @grafikrobot that was so fast I went to the issues and went "I thought I filed this as a bug; why is it not there?" :) wow