Skip to content

More descriptive error message when required option is not present #503

Closed
@markpollack

Description

@markpollack

As an example, the command

	@ShellMethod(key = "catalog add", value = "Add a project to a project catalog")
	public void catalogAdd(
			@ShellOption(help = "Catalog name", arity = 1) String name,
			@ShellOption(help = "Catalog url", arity = 1) String url,
			@ShellOption(help = "Catalog description", defaultValue = ShellOption.NULL, arity = 1) String description,
			@ShellOption(help = "Project tags", defaultValue = ShellOption.NULL, arity = 1) List<String> tags
	) {

when the name option is not specified

spring:>catalog add --url https://github.com/rd-1-2022/spring-gs-catalog
Missing option, longnames='name', shortnames=''

It would also be useful to use the help message to help convey the missing option to the user. The use of longnames and shortnames is also sort of confusing as they are terms only know to those very familiar with the implementation of the shell when using the DSL and those terms are not used in the annotation programming model, and not exposed to the end user at all.

Something along the lines of

spring:>catalog add --url https://github.com/rd-1-2022/spring-gs-catalog
Missing mandatory option "--name", Catalog name.  Use the command "help catalog add" for additional information on command options

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions