TVPN/src/main/kotlin/tech/nevets/tvpn/cli/commands/HelpCmd.kt
Steven Tracey dd8970758a
Some checks failed
TVPN Actions Workflow / build (push) Has been cancelled
[CI SKIP] Added kotlin 😢
2024-10-28 18:15:23 -04:00

45 lines
1.2 KiB
Kotlin

package tech.nevets.tvpn.cli.commands
import tech.nevets.tvpn.cli.Command
import tech.nevets.tvpn.cli.CommandBrigadier
import kotlin.system.exitProcess
class HelpCmd(private val cb: CommandBrigadier) : Command {
override fun execute(args: Array<String>) {
if (args.isNotEmpty()) {
for (c in cb.getCommands()) {
if (args.size != 1 && args[1] == c.getName()) {
println(("TVPN - Usage Menu [" + c.getName()) + "]")
println((c.getName() + " " + c.getUsage()) + ": " + c.getDescription())
exitProcess(0)
}
}
}
val sb = StringBuilder()
sb.append("TVPN - Help Menu\n")
for (c in cb.getCommands()) {
sb.append(" - ").append(c.getName())
.append(" ").append(c.getUsage())
.append(": ").append(c.getDescription())
.append("\n")
}
println(sb)
exitProcess(0)
}
override fun getName(): String {
return "help"
}
override fun getUsage(): String {
return ""
}
override fun getDescription(): String {
return "Displays the help menu"
}
}