argparse icon indicating copy to clipboard operation
argparse copied to clipboard

added required options

Open zinccyy opened this issue 4 years ago • 4 comments

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.

zinccyy avatar Aug 25 '20 22:08 zinccyy

[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.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

cofyc-bot avatar Aug 25 '20 22:08 cofyc-bot

/assign @cofyc

zinccyy avatar Aug 25 '20 22:08 zinccyy

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),.

zinccyy avatar Aug 26 '20 06:08 zinccyy

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

feliwir avatar Apr 14 '22 12:04 feliwir