Skip to content

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

Closed

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

Activity

  1. changed the title [-]Boolean option without value does not property work with argument[/-] [+]Boolean option without value does not properly work with argument[/+] on Feb 1, 2026
  2. czpilar commented on Feb 1, 2026

    @czpilar
    ContributorAuthor

    Fixed in PR #1310

  3. added and removed
    status/need-triageTeam needs to triage and take a first look
    on Mar 25, 2026
  4. added this to the 4.0.2 milestone on Mar 25, 2026
  5. added a commit that references this issue on Mar 25, 2026
    0ece35e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions