Server parent command doesn't duplicate aliases anymore
MODIFY
commands/commandimpls/server.go
commands/commandimpls/server.go
@@ -2,6 +2,7 @@ package commandimpls
import (
"fmt"
+ "github.com/Bios-Marcel/cordless/commands"
"io"
"strings"
@@ -91,18 +92,17 @@ func (cmd *ServerCmd) PrintHelp(writer io.Writer) {
func (cmd *ServerCmd) Execute(writer io.Writer, parameters []string) {
if len(parameters) == 0 {
cmd.PrintHelp(writer)
- return
- }
-
- switch parameters[0] {
- case "join", "accept", "enter":
+ } else {
+ combinedName := cmd.Name() + "-" + parameters[0]
+ if commands.CommandEquals(cmd.serverJoinCmd, combinedName) {
cmd.serverJoinCmd.Execute(writer, parameters[1:])
- case "leave", "exit", "quit":
+ } else if commands.CommandEquals(cmd.serverLeaveCmd, combinedName) {
cmd.serverLeaveCmd.Execute(writer, parameters[1:])
- default:
+ } else {
cmd.PrintHelp(writer)
}
}
+}
func (cmd *ServerJoinCmd) PrintHelp(writer io.Writer) {
fmt.Fprintln(writer, serverJoinHelpPage)

Server parent command doesn't duplicate aliases anymore