JasperFx / oakton

Parsing and Utilities for Command Line Tools in .Net
http://jasperfx.github.io/oakton
Apache License 2.0
308 stars 41 forks source link

Mandatory arguments #73

Open reegeek opened 1 year ago

reegeek commented 1 year ago

Hi, First of all, thank for sharing your project.

It is possible to mark some arguments as mandatory ?

mandatory in the sense that if they are missing then we have an error.

mysticmind commented 1 year ago

I think by default it is mandatory. Only if your property name has a Flag suffix, it is treated as optional. Please check and revert.

reegeek commented 1 year ago

Indeed Flag are optional. I have just modify quick start example by:

 public class NameInput
    {
        [Description("The name to be printed to the console output")]
        public string Name { get; set; }

        [Description("The name to be printed to the console output")]
        public string Name2 { get; set; }

        [Description("The color of the text. Default is black")]
        public ConsoleColor ColorFlag { get; set; } = ConsoleColor.Black;

        [Description("Optional title preceeding the name")]
        public string TitleFlag { get; set; }
    }

Name and Name2 are mandatories but I cannot set Name2. Following syntax not working: dotnet run -- name titi toto -c Red