Replies: 5 comments 7 replies
-
To you question I have a hard time to understand what you mean. Is this about command file? Can you show a real example what happens with a shell. |
Beta Was this translation helpful? Give feedback.
-
Hi @jvalkeal , Thank you very much for your reply. It is about command line param. As shown in the example below: public class MainShell {
public static void main(String[] args) throws Exception {
Bootstrap bootstrap = new Bootstrap();
JLineShellComponent shell = bootstrap.getJLineShellComponent();
shell.executeCommand("command --str */*/*");
}
} @Component
public class MyCommand implements CommandMarker {
@CliCommand(value = "command")
public String execCommand(
@CliOption(key = {"str"}) String str
) throws Exception {
return str;
}
} The problem is, when we pass AbstractShell::executeCommand: // We support simple block comments; ie a single pair per line
if (!inBlockComment && line.contains("/*") && line.contains("*/")) {
blockCommentBegin();
String lhs = line.substring(0, line.lastIndexOf("/*"));
if (line.contains("*/")) {
line = lhs + line.substring(line.lastIndexOf("*/") + 2);
blockCommentFinish();
} else {
line = lhs;
}
}
if (inBlockComment) {
if (!line.contains("*/")) {
return new CommandResult(true);
}
blockCommentFinish();
line = line.substring(line.lastIndexOf("*/") + 2);
}
// We also support inline comments (but only at start of line, otherwise valid
// command options like http://www.helloworld.com will fail as per ROO-517)
if (!inBlockComment && (line.trim().startsWith("//") || line.trim().startsWith("#"))) { // # support in ROO-1116
line = "";
} Also I got two more questions and need some help:
|
Beta Was this translation helpful? Give feedback.
-
This is from hoodie right? Unfortunately you are on an unsupported stack here as this is such an old code. Part of that code in shell 1.x code originates from spring roo(which means we're talking 10+ years). Spring Boot then became later which these days is the bootstrapping framework. If you need to fix something on spring-shell 1.x I think only option is to fork it and make needed quick fixes to give more time for possible rework/overhaul on top of more modern spring-shell. Since early days of spring shell 1.x it has been rewritten two times so very little is in place these days. What comes for your question 1, it's not valid as offending code is not there anymore. About your question 2; Spring shell 1.x used spring-framework as spring-boot didn't exist at that time, thus the Also if you choose to migrate, you have a good path forward to keep dependencies up-to-date, get a change to be on a supported versions from both spring and jdk. |
Beta Was this translation helpful? Give feedback.
-
I think it's better to move this into discussion. |
Beta Was this translation helpful? Give feedback.
-
Hi @jvalkeal , I got a problem and need your help. How could I run the shell command via Java code in 2.1.1 like those in 1.2.1.RELEASE: Bootstrap bootstrap = new Bootstrap();
JLineShellComponent shell = bootstrap.getJLineShellComponent();
shell.executeCommand("help"); We need to upgrade the unit tests. Thank you very much. |
Beta Was this translation helpful? Give feedback.
-
Affect version: Spring-shell 1.2.0.RELEASE
In 1.2.0.RELEASE spring shell tends to erase everything between block command quotes.
However sometime we do not need this feature as we might need to pass a URL regex like '*/*/*'. If doing so, spring shell will keep characters before last '/*' and after last '*/'. As a result we get '*/**', which is buggy.
I suggest we had better introduce a configuration that can enable/disable block comment processing.
Beta Was this translation helpful? Give feedback.
All reactions