Skip to content
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

Use correct has_arg when parsing command line options with getopt_long #530

Merged
merged 4 commits into from
Oct 19, 2022

Conversation

scareything
Copy link
Member

getopt_long takes an array of struct option to represent recognized command line options. struct option has a field has_arg which specifies whether or not the command line option has an associated argument; possible values are:

  • no_argument: no argument to the option is expected
  • required_argument: an argument to the option is required
  • optional_argument: an argument to the option may be presented

We've been incorrectly setting this field to optional_argument in some cases when the intent was to make the command line option itself optional. This PR sets has_arg to required_argument where appropriate, and adds logic to ensure that required options are passed.

@scareything scareything requested a review from a team as a code owner October 19, 2022 15:33
Copy link
Member

@dovholuknf dovholuknf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@scareything scareything merged commit 91b276f into main Oct 19, 2022
@scareything scareything deleted the use.correct.getopt_long.has_arg branch October 19, 2022 15:40
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