Long option name tokens are parsed as previous option value

Open
#78 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
cli

Research direction

Start with src/cmdline.cpp around line 477 and reproduce the command line containing --option_with_value --known_option. Trace how the token is passed to find_nothrow and verify that the known long option is recognized instead of consumed as the previous string option's value; add coverage for the long-option case and confirm the existing short-option behavior remains unchanged.

Written by the indexing model from the issue text.

Description

https://github.com/boostorg/program_options/blob/d95d31684832075fda04c9fc916f8ec875552763/src/cmdline.cpp#L477

If long option follows an option with (string) value, it is parsed as value instead of known option. For example in command line "--option_with_value --known_option", option_with_value will have value equal to "--known_option". This issue does not occur if following option is in short format.

As I understand the code, find_nothrow in referenced file is given token with leading dashes instead of option's string_key (or name).

Dominant language
C++
Stars
136
Forks
117
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/program_options

All issues in boostorg/program_options

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.