Designate Required vs Optional Parameters/Options
See original GitHub issueCurrently, it is up to the application developer using CommandLineUtils
to validate command line input and display an appropriate error if an Option that is required is left out. I propose that CommandLineUtils
take on this responsibility, allowing the library user to designate parameters as required and provide appropriate feedback to the user when the parameter is not provided.
This may be a nice feature to do after #8 so the user of the library need only add an attribute of [Required] to make this designation.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
in python, how do you denote required parameters and ...
Parameters can be required or optional depending on how they appear in the function ... You can denote required keyword argument as follows:...
Read more >Named and Optional Arguments - C# Programming Guide
Optional arguments. The definition of a method, constructor, indexer, or delegate can specify its parameters are required or optional.
Read more >Javascript: Declaring Optional Function Paramters
By definition, an Optional Parameter is a handy feature that enables programmers to pass less number of parameters to a function and assign...
Read more >Using Python Optional Arguments When Defining Functions
In this tutorial, you'll learn about Python optional arguments and how to define functions with default values. You'll also learn how to create...
Read more >TypeScript Optional Parameters
In this tutorial, you will learn how to use the TypeScript optional parameters for functions.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thought about it more, here is what I’m thinking. Would like your feedback.
Attributes
Design:
Support any implementation of System.ComponentModel.DataAnnotations.ValidationAttribute. This includes
RequiredAttribute
and others.Result: When validation fails, the application exits with code 1 and prints an error message.
Usage:
Builder api
Design: Add extension methods that build of
CommandOption
, such as.IsRequired()
. These should roughly map to the same values provided byRequiredAttribute
and others.Usage:
This is now available in 2.1.0-rc.
https://www.nuget.org/packages/McMaster.Extensions.CommandLineUtils/2.1.0-rc