spring-projects / spring-shell

Spring based shell
http://projects.spring.io/spring-shell/
Apache License 2.0
710 stars 391 forks source link

Feature Request: Tell Spring Shell to ignore command line arguments #994

Open siddhsql opened 5 months ago

siddhsql commented 5 months ago

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

jvalkeal commented 5 months ago

Duplicate of #508

MirkoDostmann commented 3 weeks ago

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.