spectre.console icon indicating copy to clipboard operation
spectre.console copied to clipboard

Settings with multiple arguments out of order in command help text

Open DarthPedro opened this issue 5 years ago • 2 comments

If you have a settings class with multiple arguments defined as follows:

        public class Settings : CommandSettings
        {
            [CommandArgument(0, "<ID>")]
            [Description("New student unique id.")]
            public int Id { get; set; }

            [CommandArgument(1, "<FIRST-NAME>")]
            [Description("New student first name.")]
            public string FirstName { get; set; }

            [CommandArgument(2, "<LAST-NAME>")]
            [Description("New student last name.")]
            public string LastName { get; set; }

            [CommandOption("-e|--enrollment <DATE>")]
            [Description("New student enrollment date.")]
            public DateTimeOffset? EnrollmentDate { get; set; }
        }

If you look for the command help text using the command line: app student new -h

USAGE:
    lesson student new <LAST-NAME> <FIRST-NAME> <ID> [OPTIONS]

EXAMPLES:
    lesson student new 1001 Bill Shakespeare --enrollment 5/14/1549

ARGUMENTS:
    <ID>            New student unique id
    <FIRST-NAME>    New student first name
    <LAST-NAME>     New student last name

OPTIONS:
    -h, --help                 Prints help information
    -e, --enrollment <DATE>    New student enrollment date

The USAGE section has the arguments in reverse order. The ARGUMENTS section order is correct. But if you run the following help command: app student -h:

USAGE:
    lesson student [OPTIONS] <COMMAND>

EXAMPLES:
    lesson student new 1001 Bill Shakespeare --enrollment 5/14/1549
    lesson student view 1001
    lesson student list
    lesson student delete 1001

OPTIONS:
    -h, --help    Prints help information

COMMANDS:
    new <ID> <FIRST-NAME> <LAST-NAME>    Add new student information
    view <ID>                            View student information by id
    list                                 View list of students
    delete <ID>                          Remove student from list

Notice that the new COMMAND argument order is correct here.

DarthPedro avatar Dec 11 '20 06:12 DarthPedro

@DarthPedro Thanks for reporting this. Will take a look once I have some spare time.

patriksvensson avatar Dec 11 '20 08:12 patriksvensson

Thanks!

DarthPedro avatar Jan 01 '21 18:01 DarthPedro