-
Notifications
You must be signed in to change notification settings - Fork 395
Open
Labels
status/need-triageTeam needs to triage and take a first lookTeam needs to triage and take a first look
Description
There is a mixup of @Option shortName mapping when there is a specific shortName defined by an Option but another Options longName starts with the same letter. There seems to be some kind of default/fallback logic that ignores explicit mapping on other parameters.
Example Command
@Component
class Demo {
@Command(name = "demo")
String demo(
@Option(longName = "aWrong") String aWrong,
@Option(longName = "intendedA", shortName = 'a') String aIntended
) {
return "aWrong=%s intendedA=%s".formatted(aWrong, aIntended);
}
}Test
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.shell.test.ShellTestClient;
import org.springframework.shell.test.autoconfigure.ShellTest;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE;
import static org.springframework.shell.test.ShellAssertions.assertThat;
@ShellTest
@SpringBootTest(
webEnvironment = NONE,
properties = {"spring.shell.interactive.enabled=false"})
class ShortNameProblemTest {
@Autowired
ShellTestClient client;
@Test
void shouldPrint_correctValues() throws Exception {
var screen = client.sendCommand("demo -a intended");
assertThat(screen).containsText("aWrong= intendedA=intended");
}
}Metadata
Metadata
Assignees
Labels
status/need-triageTeam needs to triage and take a first lookTeam needs to triage and take a first look