8000 Allow default command configuration for a branch · Issue #187 · spectreconsole/spectre.console · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Allow default command configuration for a branch #187
Closed
@DarthPedro

Description

@DarthPedro

If I define a branch with multiple commands, I would like to also configure a default to be called when the root of the branch is used. For example, in the following command configuration:

                config.AddBranch("student", student =>
                {
                    student.SetDescription("View, list, add or remove students.");

                    student.AddCommand<StudentAddCommand>("new")
                        .WithAlias("add")
                        .WithDescription("Add new student information.")
                        .WithExample(new[] { "student", "new", "1001", "Bill", "Shakespeare", "--enrollment", "5/14/1549" });

                    student.AddCommand<StudentViewCommand>("view")
                        .WithDescription("View student information by id.")
                        .WithExample(new[] { "student", "view", "1001" });

                    student.AddCommand<StudentListCommand>("list")
                        .WithDescription("View list of students.")
                        .WithExample(new[] { "student", "list" });

                    student.AddCommand<StudentDeleteCommand>("delete")
                        .WithAlias("del")
                        .WithDescription("Remove student from list.")
                        .WithExample(new[] { "student", "delete", "1001" });
                });

I would like to set a default in the student configurator, like the following:
student.SetDefaultCommand<StudentListCommand>();
That way if the user types the command: myapp student; the program would process the StudentListCommand.
Currently without the default, it shows the student help text.

@patriksvensson I would love to start contributing some fixes to thi 5E79 s library. If there are easy bugs to fix, like the ones I've posted, that might be a good place to start.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done 🚀

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0