Skip to content

Fix an additional space in help generated #377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 9, 2022

Conversation

soumeh01
Copy link
Contributor

@soumeh01 soumeh01 commented Nov 4, 2022

Problem:

In the scenario when command line args don't have any options and have only positional args. The help generated shows an extra space when we try to set custom help to empty string in order to overwrite the default [OPTION...] string in the help.

cxxopts::Options options{"test", ""};
std::vector<std::string> positional;
options
  .positional_help("<posArg1>...<posArgN>")
  .custom_help("")
  .add_options()
    ("positional", "", cxxopts::value<std::vector<std::string>>(positional));

options.parse_positional({"positional"});
std::vector<const char*> arg = {"pos1", "pos2", "pos3"};
auto r = o.parse(arg.size(), arg.data());
cout<<options.help();

Current generated help

Usage:
  test  <posArg1>...<posArgN>

Note: there are 2 spaces between test and <posArg1>

Expected help

Usage:
  test <posArg1>...<posArgN>

This change is Reviewable

@jarro2783 jarro2783 merged commit 1dcb44e into jarro2783:master Nov 9, 2022
@jarro2783
Copy link
Owner

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants