Start work on commands
This commit is contained in:
parent
8d04b002bb
commit
aa4e6d8aa8
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
package matterlink.bridge.command
|
||||
|
Loading…
Reference in New Issue