Skip to content

show help if validate fail #1451

Discussion options

You must be logged in to vote

Is there a way to do this?

Yes, it's done out of the box by simply using spectre.console

Here's an example application with a single command and a mandatory argument:

namespace ConsoleApp1
{
    public sealed class DogSettings : CommandSettings
    {
        [CommandArgument(0, "<AGE>")]
        public int Age { get; set; }
    }

    public class DefaultCommand : Command<DogSettings>
    {
        public override int Execute(CommandContext context, DogSettings settings)
        {
            AnsiConsole.WriteLine($"Dog age {settings.Age}");
            return 0;
        }
    }

    public class Program
    {
        static void Main(string[] args)
        {
            var app = new C…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by AlessandroMenchiniTmaxLab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants