Skip to content

Boolean option without value does not properly work with argument #1309

@czpilar

Description

@czpilar

As it was mentioned in the comment here boolean option without value does not properly work with argument:
#1304 (comment)

Considering this configuration:

package org.springframework.shell.samples.helloworld.boot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.shell.core.command.annotation.Argument;
import org.springframework.shell.core.command.annotation.Command;
import org.springframework.shell.core.command.annotation.Option;

@SpringBootApplication
public class SpringShellApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringShellApplication.class, args);
	}

	@Command(name = "rm")
	public String rm(@Option(shortName = 'f', defaultValue = "false") boolean force, @Argument(index = 0) String name) {
		return "Removed " + name + " force " + force;
	}

}

It does not work as shell:>rm --force filename
But it works as shell:>rm filename --force

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    status/need-triageTeam needs to triage and take a first look

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions