Skip to content

Context don't close #863

Closed
Closed
@denberr95

Description

@denberr95

HOW TO USE

  1. VSCode
  2. Spring Boot 3.1.3
  3. Spring Shell 3.1.3

WHAT I'M DOING

I'm using new annotation model for implement a command line.
In my use case i need that my commands are executable with non-interactive mode.
I need after command completion that session will be closed automatically.

WHAT HAPPEN

This is my custom command

@Command(group = "Profiles Commands", command = "profile")
public class ProfilesCmd {

    @Autowired
    private ShellCommandsHandler component;

    @Command(description = "Register a cluster into a credential file", command = "create", interactionMode = InteractionMode.ALL)
    public void create(
            @Option(description = "Name of the cluster", required = true) String name,
            @Option(description = "Setup topology of API Management (Accepted values: CLOUD, LOCAL)", required = true) @Pattern(message = "Accepted values: CLOUD, LOCAL", regexp = "CLOUD|LOCAL") String envType,
            @Option(description = "API host", defaultValue = "api.mashery.com") String apiHost,
            @Option(description = "API port", defaultValue = "443") int apiPort,
            @Option(description = "API Base Path", defaultValue = "/v3") String apiBasePath,
            @Option(description = "Enable HTTPS", defaultValue = "true") boolean useSsl,
            @Option(description = "Flag to run command in interactive or non-interactive mode, default is true", defaultValue = "true") boolean interactive) {
        component.createProfile(name, envType, apiHost, apiPort, apiBasePath, useSsl);
    }
}

This is my application.properties where I disabled scrips and interactive mode:

################### SPRING SHELL CONFIG ###################
spring.shell.command.version.enabled=true
spring.shell.command.version.show-build-artifact=false
spring.shell.command.version.show-build-group=false
spring.shell.command.version.show-build-name=true
spring.shell.command.version.show-build-time=true
spring.shell.command.version.show-build-version=true
spring.shell.command.version.show-git-commit-id=true
spring.shell.command.version.show-git-commit-time=false
spring.shell.command.version.show-git-short-commit-id=true
spring.shell.command.history.enabled=true
spring.shell.history.name=logs/shell-history.log
spring.shell.command.clear.enabled=true
spring.shell.command.completion.enabled=true
spring.shell.command.help.enabled=true
spring.shell.command.help.grouping-mode=GROUP
spring.shell.command.quit.enabled=true
spring.shell.command.stacktrace.enabled=true
spring.shell.interactive.enabled=false
spring.shell.noninteractive.enabled=true
spring.shell.script.enabled=false

When I run the command in non-interactive mode The program wait the SIGTERM:
image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions