spring-shell icon indicating copy to clipboard operation
spring-shell copied to clipboard

Feature Request: Tell Spring Shell to ignore command line arguments

Open siddhsql opened this issue 1 year ago • 2 comments
trafficstars

Context: I am developing a spring shell application. I want to be able to pass Spring ConfigurationProperties via the command line to the application.

Problem: The problem is that if I try to pass the ConfigurationProperties via the command line e.g.:

java -jar myapp.jar --flag1=value1 --flag2=value2

Spring Boot correctly parses --flag1=value1 --flag2=value2 as external configuration but then Spring shell tries to interpret

--flag1=value1 --flag2=value2

as a shell command which it is not.

Please provide a solution to this problem.

SO question: https://stackoverflow.com/questions/77462680/how-to-tell-spring-shell-to-not-parse-command-line-arguments-as-shell-commands

siddhsql avatar Jan 27 '24 18:01 siddhsql

Duplicate of #508

jvalkeal avatar Jan 28 '24 08:01 jvalkeal

I was able to solve this with a workaround as suggested in the abovementioned SO post, specifically by configuring a custom ShellRunner that decorates the given ShellRunner-implementation and simply filtering the args passed to the run -Method of the decorated ShellRunner-implementation.

However, I think it should be possible to filter args automatically by utilising the CommandCatalog, passing only those args to the shell that match a command or an option registered in the CommandCatalog.

Any thoughts on that idea by the maintainers? I could probably provide a PR.

MirkoDostmann avatar Jul 01 '24 08:07 MirkoDostmann