Skip to content

Commit 49f9b78

Browse files
committed
feat(sample): add CLI example
1 parent e212c2d commit 49f9b78

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

sample/build.gradle.kts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithHostTests
2+
3+
plugins {
4+
application
5+
kotlin("multiplatform")
6+
}
7+
8+
fun KotlinNativeTargetWithHostTests.configureTarget() =
9+
binaries { executable { entryPoint = "main" } }
10+
11+
kotlin {
12+
js(LEGACY) {
13+
browser()
14+
nodejs()
15+
binaries.executable()
16+
compilations.all {
17+
kotlinOptions {
18+
moduleKind = "umd"
19+
sourceMap = true
20+
sourceMapEmbedSources = null
21+
}
22+
}
23+
}
24+
ios()
25+
linuxX64 { configureTarget() }
26+
mingwX64 { configureTarget() }
27+
macosX64 { configureTarget() }
28+
29+
sourceSets {
30+
sourceSets["commonMain"].apply {
31+
dependencies {
32+
implementation(project(":"))
33+
}
34+
}
35+
}
36+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import com.github.androidpasswordstore.sublimefuzzy.Fuzzy
2+
3+
fun main() {
4+
val simpleMatchData = mapOf(
5+
("test" to "tests") to true,
6+
("test" to "tset") to false,
7+
)
8+
val matchData = mapOf(
9+
("fot" to "FbxImporter.h") to (true to 105),
10+
("fot" to "kot") to (false to 0),
11+
)
12+
simpleMatchData
13+
.forEach { (match, expected) ->
14+
val result = Fuzzy.fuzzyMatchSimple(match.first, match.second)
15+
require(result == expected) {
16+
"Simple match result for '${match.first}' and '${match.second}' was $result, should've been $expected"
17+
}
18+
println("[RESULT]: ${match.first} to ${match.second} = $result")
19+
}
20+
matchData
21+
.forEach { (match, expected) ->
22+
val (result, score) = Fuzzy.fuzzyMatch(match.first, match.second)
23+
require(result == expected.first && score == expected.second) {
24+
"Simple match result for '${match.first}' and '${match.second}' was ($result, $score), should've been (${expected.first}, ${expected.second})"
25+
}
26+
println("[RESULT]: ${match.first} to ${match.second} = $result, $score")
27+
}
28+
}

settings.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ pluginManagement {
2323
}
2424
}
2525

26+
include("sample")
27+
2628
dependencyResolutionManagement {
2729
repositories {
2830
mavenCentral()

0 commit comments

Comments
 (0)