mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 09:56:37 -04:00
improve help command
There is still more room for improvement
This commit is contained in:
parent
09c583e1fd
commit
ea3a1a94d1
@ -13,33 +13,33 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.terminal.commands
|
package de.bixilon.minosoft.terminal.commands
|
||||||
|
|
||||||
import de.bixilon.kutil.enums.EnumUtil
|
|
||||||
import de.bixilon.kutil.enums.ValuesEnum
|
|
||||||
import de.bixilon.minosoft.commands.nodes.ArgumentNode
|
|
||||||
import de.bixilon.minosoft.commands.nodes.LiteralNode
|
import de.bixilon.minosoft.commands.nodes.LiteralNode
|
||||||
import de.bixilon.minosoft.commands.parser.minosoft.enums.EnumParser
|
|
||||||
import de.bixilon.minosoft.commands.stack.print.PrintTarget
|
import de.bixilon.minosoft.commands.stack.print.PrintTarget
|
||||||
|
|
||||||
object HelpCommand : Command {
|
object HelpCommand : Command {
|
||||||
override var node: LiteralNode = LiteralNode("help", setOf("?"), executor = { it.print.printHelp() })
|
override var node: LiteralNode = LiteralNode("help", setOf("?"), executor = { it.print.overview() })
|
||||||
.addChild(ArgumentNode("subcommand", parser = EnumParser(HelpCommands), executor = { it.print.printHelp(it["subcommand"]!!) }))
|
.addChild(LiteralNode("account", executor = { it.print.account() }))
|
||||||
|
|
||||||
fun PrintTarget.printHelp() {
|
private fun PrintTarget.overview() {
|
||||||
print("-------------- Minosoft help --------------")
|
print("-------------- Minosoft help --------------")
|
||||||
|
print("Tip: You can always press [tab] to auto complete commands and see what (sub)commands are available!")
|
||||||
|
print("Another tip: The help command has subcommands (e.g. type help account)")
|
||||||
|
print("Filters: Most commands takes filters. That can either be an identifier of something or a selector (like @). Selectors can even have properties like @[type=offline]")
|
||||||
|
print("Here are some useful commands:")
|
||||||
|
print(" account [add|remove|list|select] - Manages your accounts")
|
||||||
|
print(" connection [list|disconnect|select] - Manages the connection to a server")
|
||||||
|
print(" connect [address] <version> - Connects to a server")
|
||||||
|
print(" ping [address] <version> - Shows the motd of a server")
|
||||||
|
print(" *say* [message] - Lets you write something in the chat. Requires a selected connection.")
|
||||||
|
print(" about - Shows some useful information")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun PrintTarget.printHelp(subcommand: HelpCommands) {
|
private fun PrintTarget.account() {
|
||||||
print("-------------- Minosoft help --------------")
|
print("-------------- Account help --------------")
|
||||||
print("Subcommand: $subcommand")
|
print("account add offline [username] - Adds a new offline account")
|
||||||
}
|
print("account add microsoft - Adds a new microsoft account")
|
||||||
|
print("account list <filter> - Lists all accounts")
|
||||||
enum class HelpCommands {
|
print("account select <filter> - Selects an account")
|
||||||
GENERAL,
|
print("account remove <filter> - Removes an account")
|
||||||
;
|
|
||||||
|
|
||||||
companion object : ValuesEnum<HelpCommands> {
|
|
||||||
override val VALUES: Array<HelpCommands> = values()
|
|
||||||
override val NAME_MAP: Map<String, HelpCommands> = EnumUtil.getEnumValues(VALUES)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user