CommandRegistry.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package Commands
  2. import (
  3. "git.swzry.com/NSMCServerLauncher/Terminal"
  4. "golang.org/x/crypto/ssh/terminal"
  5. "git.swzry.com/NSMCServerLauncher/Utils"
  6. )
  7. func RegistExtendCommands() {
  8. Terminal.RegistCommand("pwd",Terminal.RegistedCommand{
  9. CmdFunc: CMD_pwd_C,
  10. HelpFunc: func(topic string, term *terminal.Terminal) {},
  11. Intro:"Show current work path",
  12. Usage:"pwd",
  13. })
  14. Terminal.RegistCommand("cd",Terminal.RegistedCommand{
  15. CmdFunc: CMD_cd_C,
  16. HelpFunc: func(topic string, term *terminal.Terminal) {},
  17. Intro:"Change current work path",
  18. Usage:"cd <path>",
  19. })
  20. Terminal.RegistCommand("mcstat",Terminal.RegistedCommand{
  21. CmdFunc: CMD_mcstat_C,
  22. HelpFunc: func(topic string, term *terminal.Terminal) {
  23. //term.Write([]byte("Disconnect to the server.\n"))
  24. },
  25. Intro:"Show the Minecraft server running status.",
  26. Usage:"mcstat",
  27. })
  28. Terminal.RegistCommand("sz",Terminal.RegistedCommand{
  29. CmdFunc: CMD_sz_C,
  30. HelpFunc: func(topic string, term *terminal.Terminal) {
  31. term.Write([]byte("This command can help you download file from server using ZMODEM\n\n"))
  32. term.Write([]byte("ZMODEM is a file transfer protocol that can be carried on SSH/Telnet or other protocol.\n"))
  33. term.Write([]byte("(See also: https://en.wikipedia.org/wiki/ZMODEM)\n\n"))
  34. },
  35. Intro:"Download file from server using ZMODEM",
  36. Usage:"sz <conf|log|mc> <path_to_file>",
  37. })
  38. }
  39. func RegistInnerCommands() {
  40. Terminal.RegistCommand("help",Terminal.RegistedCommand{
  41. CmdFunc: func(args []string, term *terminal.Terminal,context *Utils.UserContextType) {},
  42. HelpFunc: func(topic string, term *terminal.Terminal) {
  43. //term.Write([]byte("Disconnect to the server.\n"))
  44. },
  45. Intro:"Show help informations.",
  46. Usage:"help\nhelp <command> [topic]",
  47. })
  48. Terminal.RegistCommand("about",Terminal.RegistedCommand{
  49. CmdFunc: func(args []string, term *terminal.Terminal,context *Utils.UserContextType) {},
  50. HelpFunc: func(topic string, term *terminal.Terminal) {
  51. //term.Write([]byte("About this system.\n"))
  52. },
  53. Intro:"About this system.",
  54. Usage:"about",
  55. })
  56. Terminal.RegistCommand("exit",Terminal.RegistedCommand{
  57. CmdFunc: func(args []string, term *terminal.Terminal,context *Utils.UserContextType) {},
  58. HelpFunc: func(topic string, term *terminal.Terminal) {
  59. //term.Write([]byte("Disconnect to the server.\n"))
  60. },
  61. Intro:"Disconnect to the server.",
  62. Usage:"exit",
  63. })
  64. }
  65. func RegistAllCommands() {
  66. Terminal.CommandSystemInit()
  67. RegistInnerCommands()
  68. RegistExtendCommands()
  69. Terminal.GenerateHelpCommandList()
  70. }