Start work on commands

This commit is contained in:
DaMachinator 2018-02-08 09:32:49 -05:00 committed by Arcanitor
parent 8d04b002bb
commit aa4e6d8aa8
3 changed files with 16 additions and 1 deletions

View File

@ -111,7 +111,7 @@ class MatterLinkConfig(file: File) {
url = config.getString(
"connectURL",
CATEGORY_CONNECTION,
"localhost:4242",
"http://localhost:4242",
"The URL or IP address of the bridge server"
),
authToken = config.getString(

View File

@ -1,2 +1,15 @@
package matterlink.bridge.command
class BridgeCommand(val name: String, command: (String) -> Boolean) {
private val execute: (String) -> Boolean = command //return true for success and false for failure
fun tryExecute(input: String): Boolean {
//get the first word
val space = input.indexOf(' ')
if (space == 0) return false //"! " is never a command
var cmd = if (space > 0) input.substring(0, space) else input
return if (cmd == name) execute(input.substring(space + 1)) else false
}
}

View File

@ -0,0 +1,2 @@
package matterlink.bridge.command