Closed akshay232 closed 8 months ago
Do you have any errors logged?
I noticed that @
may be wrongly interpreted to get used with ScriptShellRunner
but if that's the issue you'd see it in logs.
Do you have any errors logged?
I noticed that
@
may be wrongly interpreted to get used withScriptShellRunner
but if that's the issue you'd see it in logs.
I dont see any error. Just it is coming as null while i am printing it. other characters are working like $ # %. @ was working with older spring shell version (2.0.1 something) but i am currently having 3.0.2 for it is not working
Can you create a minimal sample I could run myself. I'm not able to reproduce your issue.
Can you create a minimal sample I could run myself. I'm not able to reproduce your issue.
Here is the sample. Dependency: spring-shell-core 3.0.2
Commands.java
@ShellMethod(value = "Test Method", key = "test") public String version(@ShellOption(help = "Variable delimiter", value = "-d", defaultValue = "@") String delimiter) { System.out.println("In Test"); System.out.println("*** " + delimiter); return null; }
SpringMain.class
SpringApplication.run(MainApp.class, args);
OUTPUT Command: java -jar package.jar test -d "@" In Test *** null
I can't reproduce. With that you'd get:
Caused by: java.io.FileNotFoundException: (No such file or directory)
at java.base/java.io.FileInputStream.open0(Native Method) ~[na:na]
at java.base/java.io.FileInputStream.open(FileInputStream.java:216) ~[na:na]
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157) ~[na:na]
at java.base/java.io.FileReader.<init>(FileReader.java:75) ~[na:na]
at org.springframework.shell.jline.ScriptShellRunner.run(ScriptShellRunner.java:81) ~[spring-shell-core-3.0.2.jar!/:3.0.2]
Which is a bug I mentioned. Disabling script runner with:
spring:
shell:
script:
enabled: false
I then get:
java -jar build/libs/demo-0.0.1-SNAPSHOT.jar test -d "@"
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.0.13)
2024-01-29T13:53:32.052Z INFO 1877536 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication v0.0.1-SNAPSHOT using Java 17.0.7 with PID 1877536 (/home/jvalkealahti/repos/tmp/demo1/build/libs/demo-0.0.1-SNAPSHOT.jar started by jvalkealahti in /home/jvalkealahti/repos/tmp/demo1)
2024-01-29T13:53:32.056Z INFO 1877536 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to 1 default profile: "default"
2024-01-29T13:53:33.014Z INFO 1877536 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 1.424 seconds (process running for 1.937)
In Test
*** @
That's why I asked a project sample I could compile and run so that we're running same code.
Closing due to inactivity
Spring shell @ symbol is coming as null from cli to ShellMethod ShellOption attribute. @ShellOption(help = "Variable delimiter", value = "--delimiter", defaultValue = "@") String delimiter I am passing --delimiter "@" from cli, I printed it, it is comming correctly in Spring boot main app command line args but when it reaches to ShellOption of ShellMethod becomes null,