argparse
argparse copied to clipboard
added required options
Hi, I added a required options feature by adding a new field parsed to the option struct and a OPT_REQUIRED flag so that every parsed option is checked after parsing so if the option is required and if it doesn't exist the program exits. Unfortunately, by the need to change the field in a struct I had to remove the const attribute of the struct parameters.
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: mcindrich
To complete the pull request process, please assign cofyc
You can assign the PR to them by writing /assign @cofyc
in a comment when ready.
The full list of commands accepted by this bot can be found here.
Approvers can indicate their approval by writing /approve
in a comment
Approvers can cancel approval by writing /approve cancel
in a comment
/assign @cofyc
I didn't update test_argparse.c because it would then break the current tests. You use this option by providing OPT_REQUIRED flag to the option flags. For example: OPT_BOOLEAN('f', "force", &force, "force to do", NULL, 0, OPT_REQUIRED),
.
Hi, I added a required options feature by adding a new field parsed to the option struct and a OPT_REQUIRED flag so that every parsed option is checked after parsing so if the option is required and if it doesn't exist the program exits. Unfortunately, by the need to change the field in a struct I had to remove the const attribute of the struct parameters.
i like the design of just having to add a flag