Skip to content

Commit eaece3d

Browse files
authored
Merge pull request #33 from SOFTNETWORK-APP/fix/repl
fix repl bugs
2 parents 1519d05 + b704cf5 commit eaece3d

5 files changed

Lines changed: 16 additions & 10 deletions

File tree

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ThisBuild / organization := "app.softnetwork"
2020

2121
name := "softclient4es"
2222

23-
ThisBuild / version := "0.16.0"
23+
ThisBuild / version := "0.16.1"
2424

2525
ThisBuild / scalaVersion := scala213
2626

core/src/main/scala/app/softnetwork/elastic/client/GatewayApi.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ class TableExecutor(
11811181
val pipeline = IngestPipeline(
11821182
name = pipelineName,
11831183
json = maybePipeline.get,
1184-
pipelineType = Some(IngestPipelineType.Default)
1184+
pipelineType = Some(pipelineType)
11851185
)
11861186
// compute diff for pipeline update
11871187
val pipelineDiff: List[PipelineDiff] = pipeline.diff(table.defaultPipeline)
@@ -1438,7 +1438,7 @@ class TableExecutor(
14381438
.indexSettings
14391439
)
14401440
.toEither
1441-
} else Right(false)
1441+
} else Right(true)
14421442
}
14431443

14441444
steps ++= Seq(

core/src/main/scala/app/softnetwork/elastic/client/repl/Repl.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ class Repl(
138138
multilineBuffer.clear()
139139
handleMetaCommand(trimmed)
140140

141-
// Backslash commands: \h, \q, \t, etc.
142-
case _ if firstChar == 104 =>
141+
// Backslash commands: JLine strips the leading \ and delivers just the letter(s)
142+
case _ if backslashCommands.contains(firstWord) =>
143143
multilineBuffer.clear()
144144
handleBackslashCommand(trimmed)
145145

@@ -572,17 +572,20 @@ class Repl(
572572
private def formatLigne(value: String, size: Int): String = {
573573
// Supprime les espaces en début et fin de ligne
574574
val trimmedValue = value.trim
575+
val visibleLength = stripAnsi(trimmedValue).length
575576

576577
// Vérifie la longueur du texte
577-
if (trimmedValue.length > size) {
578+
if (visibleLength > size) {
578579
// Si le texte est trop long, le tronquer avec '...'
579580
trimmedValue.take(size - 3) + "..."
580581
} else {
581582
// Sinon, on complète avec des espaces
582-
trimmedValue + " " * (size - trimmedValue.length)
583+
trimmedValue + " " * (size - visibleLength)
583584
}
584585
}
585586

587+
private def stripAnsi(s: String): String = s.replaceAll("\u001B\\[[;\\d]*m", "")
588+
586589
private def printGoodbyeBanner(): Unit = {
587590
println(s"\n${emoji("👋")} ${cyan("Goodbye!")}\n")
588591
}

core/src/main/scala/app/softnetwork/elastic/client/result/ResultRenderer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ object ResultRenderer {
199199
if (success) {
200200
s"${emoji("")} ${green("Success")} ${gray(s"(${executionTime.toMillis}ms)")}"
201201
} else {
202-
s"${emoji("")} ${red("Failed")} ${gray(s"(${executionTime.toMillis}ms)")}"
202+
s"${emoji("ℹ️")} ${gray("No changes")} ${gray(s"(${executionTime.toMillis}ms)")}"
203203
}
204204
}
205205

sql/src/main/scala/app/softnetwork/elastic/sql/schema/package.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,10 @@ package object schema {
12371237
}
12381238

12391239
case class ColumnNotFound(column: String, table: String)
1240-
extends Exception(s"Column $column does not exist in table $table")
1240+
extends Exception(s"Column $column does not exist in table $table")
1241+
1242+
case class ColumnAlreadyExists(column: String, table: String)
1243+
extends Exception(s"Column $column already exists in table $table")
12411244

12421245
case class TableAlias(
12431246
table: String,
@@ -1522,7 +1525,7 @@ package object schema {
15221525
if (ifNotExists && table.cols.contains(column.name)) table
15231526
else if (!table.cols.contains(column.name))
15241527
table.copy(columns = table.columns :+ column)
1525-
else throw ColumnNotFound(column.name, table.name)
1528+
else throw ColumnAlreadyExists(column.name, table.name)
15261529
case DropColumn(columnName, ifExists) =>
15271530
if (ifExists && !table.cols.contains(columnName)) table
15281531
else if (table.cols.contains(columnName))

0 commit comments

Comments
 (0)