This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-346
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-346 by this push:
new d7c97ce WIP.
d7c97ce is described below
commit d7c97cec12df835a0d72a970e0770238326d4518
Author: Aaron Radzinzski <[email protected]>
AuthorDate: Wed Jun 30 16:03:02 2021 -0700
WIP.
---
.../nlpcraft/model/tools/cmdline/NCCli.scala | 32 ++++++++++++++++++++--
.../tools/cmdline/NCCliFileNameCompleter.java | 14 ++++++++--
2 files changed, 41 insertions(+), 5 deletions(-)
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
index ff6d181..bb41df0 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
@@ -2350,7 +2350,35 @@ object NCCli extends NCCliBase {
}
else if (words.size > 1 && isFsPath(words.head, words.last))
splitEqParam(words.last) match {
- case Some((name, path)) =>
fsCompleter.fillCandidates(reader, name, path, candidates)
+ case Some((name, p)) =>
+ var path = p
+
+ var prefix = ""
+ var suffix = ""
+
+ if (path.nonEmpty) {
+ val first = path.head
+ val last = path.last
+
+ if (first == '"' || first == '\'') {
+ prefix = first.toString
+ path = path.drop(1)
+ }
+ if (last == '"' || last == '\'') {
+ suffix = last.toString
+ path = path.dropRight(1)
+ }
+ }
+
+ fsCompleter.fillCandidates(
+ reader,
+ name,
+ path,
+ prefix,
+ suffix,
+ candidates
+ )
+
case None => ()
}
else {
@@ -2541,7 +2569,7 @@ object NCCli extends NCCliBase {
)
logln()
- logln(s"${y("Tip:")} Hit ${rv(bo(" Tab "))} for auto suggestions and
completion.")
+ logln(s"${y("Tip:")} Hit ${rv(bo(" Tab "))} for commands, parameters
and paths suggestions and completion.")
logln(s" Type '${c("help")}' to get help and ${rv(bo(" ↑ "))} or
${rv(bo(" ↓ "))} to scroll through history.")
logln(s" Type '${c("quit")}' to exit.")
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliFileNameCompleter.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliFileNameCompleter.java
index a105041..14785ff 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliFileNameCompleter.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliFileNameCompleter.java
@@ -40,9 +40,17 @@ class NCCliFileNameCompleter
* @param reader Line reader for JLine.
* @param paramName Name of the parameter.
* @param pathBuf Current path string.
+ * @param prefix
+ * @param suffix
* @param candidates List of completion candidates to fill.
*/
- void fillCandidates(LineReader reader, String paramName, String pathBuf,
final List<Candidate> candidates) {
+ void fillCandidates(
+ LineReader reader,
+ String paramName,
+ String pathBuf,
+ String prefix,
+ String suffix,
+ final List<Candidate> candidates) {
Path curPath;
String curBuf;
@@ -75,7 +83,7 @@ class NCCliFileNameCompleter
if (Files.isDirectory(path)) {
candidates.add(
new Candidate(
- paramName + "=" + value +
(reader.isSet(LineReader.Option.AUTO_PARAM_SLASH) ? sep : ""),
+ paramName + "=" + prefix + value +
(reader.isSet(LineReader.Option.AUTO_PARAM_SLASH) ? sep : "") + suffix,
getDisplay(reader.getTerminal(), path,
resolver, sep),
null,
null,
@@ -87,7 +95,7 @@ class NCCliFileNameCompleter
} else {
candidates.add(
new Candidate(
- paramName + "=" + value,
+ paramName + "=" + prefix + value + suffix,
getDisplay(reader.getTerminal(), path,
resolver, sep),
null,
null,