commandlineparser / commandlineparser/commandline

Support for arguments that require each other but are optional

Open
#383 2 comments 2 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.8k
Forks
478
PR merge metrics
No merged PRs in 30d

Description

Similar to the MutuallyExclusiveSet, it would be very helpful to be able to specify that if argument A is specified then argument B is required, but if A is not specified, then B is optional.

This may be a very specific use case, and I wouldn't even pursue it, but I'm having difficulty using the built in HelpWriter when my additional validation fails, since this validation is outside of the normal flow.

An alternative would be to support passing a Function to something like parser.CustomValidation() where the developer could get the parsed options (that were properly parsed) and run additional validation checks. If a check fails the developer can raise an exception.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the existing MutuallyExclusiveSet and HelpWriter implementations, then review how parsed options and validation failures flow through the parser. Compare the requested dependent-optional arguments with the proposed CustomValidation function; done means one agreed behavior is implemented and its help/error handling is covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.