using Ookii.CommandLine.Validation;
using System.ComponentModel;
args = new[] { "-Help" };
var options = new ParseOptions()
UseErrorColor = TriState.False,
UsageWriter = new UsageWriter(useColor: TriState.False)
var arguments = CommandLineParser.Parse<ProgramArguments>(args, options);
Console.WriteLine($"Happy birthday, {arguments.Name}!");
Console.WriteLine($"Hello {arguments.Name}.");
if (arguments.Age != null)
Console.WriteLine($"You are {arguments.Age} years old.");
if (arguments.FavoriteAnimal != Animal.Unspecified)
Console.WriteLine($"Your favorite animal is a {arguments.FavoriteAnimal}.");
[ApplicationFriendlyName("OokiiCommandLine Sample")]
[Description("Displays a message based on the command line arguments.")]
partial class ProgramArguments
[CommandLineArgument(Position = 0)]
[Description("Specifies your name.")]
public required string Name { get; set; }
[CommandLineArgument(Position = 1)]
[Description("Specifies your age.")]
[ValueDescription("Number")]
public int? Age { get; set; }
[CommandLineArgument(IsShort = true)]
[Description("Indicates if it's your birthday.")]
public bool Birthday { get; set; }
[CommandLineArgument(DefaultValue = Animal.Unspecified, IsShort = true)]
[Description("Indicates your favorite animal.")]
public Animal FavoriteAnimal { get; set; }