aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Tinc.kt22
1 files changed, 14 insertions, 8 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt b/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt
index 0bb1da4..6acd4f2 100644
--- a/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt
+++ b/app/src/main/java/org/pacien/tincapp/commands/Tinc.kt
@@ -27,15 +27,21 @@ object Tinc {
27 .thenApply<String> { it.joinToString("\n") } 27 .thenApply<String> { it.joinToString("\n") }
28 28
29 fun init(netName: String, nodeName: String): CompletableFuture<String> = 29 fun init(netName: String, nodeName: String): CompletableFuture<String> =
30 Executor.call(Command(AppPaths.tinc().absolutePath) 30 if (netName.isBlank())
31 .withOption("config", AppPaths.confDir(netName).absolutePath) 31 CompletableFuture.failedFuture(IllegalArgumentException("Network name cannot be blank."))
32 .withArguments("init", nodeName)) 32 else
33 .thenApply<String> { it.joinToString("\n") } 33 Executor.call(Command(AppPaths.tinc().absolutePath)
34 .withOption("config", AppPaths.confDir(netName).absolutePath)
35 .withArguments("init", nodeName))
36 .thenApply<String> { it.joinToString("\n") }
34 37
35 fun join(netName: String, invitationUrl: String): CompletableFuture<String> = 38 fun join(netName: String, invitationUrl: String): CompletableFuture<String> =
36 Executor.call(Command(AppPaths.tinc().absolutePath) 39 if (netName.isBlank())
37 .withOption("config", AppPaths.confDir(netName).absolutePath) 40 CompletableFuture.failedFuture(IllegalArgumentException("Network name cannot be blank."))
38 .withArguments("join", invitationUrl)) 41 else
39 .thenApply<String> { it.joinToString("\n") } 42 Executor.call(Command(AppPaths.tinc().absolutePath)
43 .withOption("config", AppPaths.confDir(netName).absolutePath)
44 .withArguments("join", invitationUrl))
45 .thenApply<String> { it.joinToString("\n") }
40 46
41} 47}