func (console *Console) handleMainPanelCommand() {
	for {
		tCommand := console.pretreatInput()
		var fCommand []string
		for _, command := range strings.Split(tCommand, " ") {
			if command != "" {
				fCommand = append(fCommand, command)
			}
		}
		if len(fCommand) == 0 {
			fCommand = append(fCommand, "")
		}
		switch fCommand[0] {
		case "use":
			if console.expectParams(fCommand, 2, MAIN, 1) {
				break
			}
			uuidNum, _ := utils.Str2Int(fCommand[1])
			if console.isOnline(uuidNum) {
				console.nodeMode = true
				console.status = fmt.Sprintf("(node %s) >> ", fCommand[1])
				console.handleNodePanelCommand(uuidNum)
				console.status = "(admin) >> "
				console.nodeMode = false
			} else {
				printer.Fail("\r\n[*] Node %s doesn't exist!", fCommand[1])
			}
			console.ready <- true
		case "detail":
			if console.expectParams(fCommand, 1, MAIN, 0) {
				break
			}
			task := &topology.TopoTask{
				Mode: topology.SHOWDETAIL,
			}
			console.topology.TaskChan <- task
			<-console.topology.ResultChan
			console.ready <- true
		case "topo":
			if console.expectParams(fCommand, 1, MAIN, 0) {
				break
			}
			task := &topology.TopoTask{
				Mode: topology.SHOWTOPO,
			}
			console.topology.TaskChan <- task
			<-console.topology.ResultChan
			console.ready <- true
		case "":
			if console.expectParams(fCommand, 1, MAIN, 0) {
				break
			}
			console.ready <- true
		case "help":
			if console.expectParams(fCommand, 1, MAIN, 0) {
				break
			}
			ShowMainHelp()
			console.ready <- true
		case "exit":
			if console.expectParams(fCommand, 1, MAIN, 0) {
				break
			}
			console.status = "[*] Do you really want to exit stowaway?(y/n): "
			console.ready <- true
			option := console.pretreatInput()
			if option == "y" {
				keyboard.Close()
				printer.Warning("\r\n[*] BYE!")
				os.Exit(0)
			}
			console.status = "(admin) >> "
			console.ready <- true
		default:
			printer.Fail("\r\n[*] Unknown Command!\r\n")
			ShowMainHelp()
			console.ready <- true
		}
	}
}
handle ur command
package cli
import (
	"bytes"
	"fmt"
	"os"
	"strings"
	"Stowaway/admin/handler"
	"Stowaway/admin/manager"
	"Stowaway/admin/printer"
	"Stowaway/admin/topology"
	"Stowaway/global"
	"Stowaway/protocol"
	"Stowaway/share"
	"Stowaway/utils"
	"github.com/eiannone/keyboard"
)
const (
	MAIN = iota
	NODE
)
type Console struct {
	status     string
	ready      chan bool
	getCommand chan string
	shellMode  bool
	sshMode    bool
	nodeMode   bool
	topology *topology.Topology
	mgr      *manager.Manager
}
func NewConsole() *Console {
	console := new(Console)
	console.status = "(admin) >> "
	console.ready = make(chan bool)
	console.getCommand = make(chan string)
	return console
}
func (console *Console) Init(tTopology *topology.Topology, myManager *manager.Manager) {
	console.topology = tTopology
	console.mgr = myManager
}
func (console *Console) Run() {
	go console.handleMainPanelCommand()
	console.mainPanel()
}
func (console *Console) mainPanel() {
	var (
		isGoingOn    bool
		leftCommand  string
		rightCommand string
	)
	history := NewHistory()
	go history.Run()
	helper := NewHelper()
	go helper.Run()
	keysEvents, _ := keyboard.GetKeys(10)
	fmt.Print(console.status)
	for {
		event := <-keysEvents
		if event.Err != nil {
			continue
		}
		if event.Key == keyboard.KeyBackspace2 || event.Key == keyboard.KeyBackspace {
			if !console.shellMode && !console.sshMode {
				fmt.Print("\r\033[K")
				fmt.Print(console.status)
				if len(leftCommand) >= 1 {
					leftCommand = string([]rune(leftCommand)[:len([]rune(leftCommand))-1])
				}
				fmt.Print(leftCommand + rightCommand)
				notSingleNum := (len(rightCommand) - len([]rune(rightCommand))) / 2  
				singleNum := len([]rune(rightCommand)) - notSingleNum                
				fmt.Print(string(bytes.Repeat([]byte("\b"), notSingleNum*2+singleNum)))
			} else {
				notSingleNum := (len(leftCommand) - len([]rune(leftCommand))) / 2
				singleNum := len([]rune(leftCommand)) - notSingleNum
				fmt.Print(string(bytes.Repeat([]byte("\b"), notSingleNum*2+singleNum)))
				fmt.Print("\033[K")
				if len(leftCommand) >= 1 {
					leftCommand = string([]rune(leftCommand)[:len([]rune(leftCommand))-1])
				}
				fmt.Print(leftCommand + rightCommand)
				notSingleNum = (len(rightCommand) - len([]rune(rightCommand))) / 2
				singleNum = len([]rune(rightCommand)) - notSingleNum
				fmt.Print(string(bytes.Repeat([]byte("\b"), notSingleNum*2+singleNum)))
			}
		} else if event.Key == keyboard.KeyEnter {
			if !console.shellMode && !console.sshMode {
				command := leftCommand + rightCommand
				if command != "" {
					task := &HistoryTask{
						Mode:    RECORD,
						Type:    NORMAL,
						Command: command,
					}
					history.TaskChan <- task
				}
				console.getCommand <- command
				isGoingOn = false
				leftCommand = ""
				rightCommand = ""
				<-console.ready
				fmt.Print("\r\n")
				fmt.Print(console.status)
			} else {
				fmt.Print("\r\n")
				command := leftCommand + rightCommand
				console.getCommand <- command + "\n"
				if leftCommand != "" {
					var task = &HistoryTask{
						Mode:    RECORD,
						Command: command,
					}
					if console.shellMode {
						task.Type = SHELL
					} else {
						task.Type = SSH
					}
					history.TaskChan <- task
				}
				isGoingOn = false
				leftCommand = ""
				rightCommand = ""
			}
		} else if event.Key == keyboard.KeyArrowUp {
			if !console.shellMode && !console.sshMode {
				fmt.Print("\r\033[K")
				fmt.Print(console.status)
				task := &HistoryTask{
					Mode:  SEARCH,
					Type:  NORMAL,
					Order: BEGIN,
				}
				if !isGoingOn {
					history.TaskChan <- task
					isGoingOn = true
				} else {
					task.Order = NEXT
					history.TaskChan <- task
				}
				result := <-history.ResultChan
				fmt.Print(result)
				leftCommand = result
				rightCommand = ""
			} else {
				task := &HistoryTask{
					Mode:  SEARCH,
					Order: BEGIN,
				}
				if console.shellMode {
					task.Type = SHELL
				} else {
					task.Type = SSH
				}
				if !isGoingOn {
					history.TaskChan <- task
					isGoingOn = true
				} else {
					task.Order = NEXT
					history.TaskChan <- task
				}
				command := <-history.ResultChan
				notSingleNum := (len(leftCommand) - len([]rune(leftCommand))) / 2
				singleNum := len([]rune(leftCommand)) - notSingleNum
				fmt.Print(string(bytes.Repeat([]byte("\b"), notSingleNum*2+singleNum)))
				fmt.Print("\033[K")
				fmt.Print(command)
				leftCommand = command
				rightCommand = ""
			}
		} else if event.Key == keyboard.KeyArrowDown {
			if !console.shellMode && !console.sshMode {
				fmt.Print("\r\033[K")
				fmt.Print(console.status)
				if isGoingOn {
					task := &HistoryTask{
						Mode:  SEARCH,
						Type:  NORMAL,
						Order: PREV,
					}
					history.TaskChan <- task
					result := <-history.ResultChan
					fmt.Print(result)
					leftCommand = result
				} else {
					leftCommand = ""
				}
				rightCommand = ""
			} else {
				var command string
				task := &HistoryTask{
					Mode:  SEARCH,
					Order: PREV,
				}
				if console.shellMode {
					task.Type = SHELL
				} else {
					task.Type = SSH
				}
				if isGoingOn {
					history.TaskChan <- task
					command = <-history.ResultChan
				} else {
					command = ""
				}
				notSingleNum := (len(leftCommand) - len([]rune(leftCommand))) / 2
				singleNum := len([]rune(leftCommand)) - notSingleNum
				fmt.Print(string(bytes.Repeat([]byte("\b"), notSingleNum*2+singleNum)))
				fmt.Print("\033[K")
				fmt.Print(command)
				leftCommand = command
				rightCommand = ""
			}
		} else if event.Key == keyboard.KeyArrowLeft {
			if !console.shellMode && !console.sshMode {
				fmt.Print("\r\033[K")
				fmt.Print(console.status)
				if len([]rune(leftCommand)) >= 1 {
					rightCommand = string([]rune(leftCommand)[len([]rune(leftCommand))-1]) + rightCommand
					leftCommand = string([]rune(leftCommand)[:len([]rune(leftCommand))-1])
				}
				fmt.Print(leftCommand + rightCommand)
				notSingleNum := (len(rightCommand) - len([]rune(rightCommand))) / 2  
				singleNum := len([]rune(rightCommand)) - notSingleNum
				fmt.Print(string(bytes.Repeat([]byte("\b"), notSingleNum*2+singleNum)))
			} else {
				notSingleNum := (len(leftCommand) - len([]rune(leftCommand))) / 2
				singleNum := len([]rune(leftCommand)) - notSingleNum
				fmt.Print(string(bytes.Repeat([]byte("\b"), notSingleNum*2+singleNum)))
				fmt.Print("\033[K")
				if len([]rune(leftCommand)) >= 1 {
					rightCommand = string([]rune(leftCommand)[len([]rune(leftCommand))-1]) + rightCommand
					leftCommand = string([]rune(leftCommand)[:len([]rune(leftCommand))-1])
				}
				fmt.Print(leftCommand + rightCommand)
				notSingleNum = (len(rightCommand) - len([]rune(rightCommand))) / 2
				singleNum = len([]rune(rightCommand)) - notSingleNum
				fmt.Print(string(bytes.Repeat([]byte("\b"), notSingleNum*2+singleNum)))
			}
		} else if event.Key == keyboard.KeyArrowRight {
			if !console.shellMode && !console.sshMode {
				fmt.Print("\r\033[K")
				fmt.Print(console.status)
				if len([]rune(rightCommand)) > 1 {
					leftCommand = leftCommand + string([]rune(rightCommand)[:1])
					rightCommand = string([]rune(rightCommand)[1:])
				} else if len([]rune(rightCommand)) == 1 {
					leftCommand = leftCommand + string([]rune(rightCommand)[:1])
					rightCommand = ""
				}
				fmt.Print(leftCommand + rightCommand)
				notSingleNum := (len(rightCommand) - len([]rune(rightCommand))) / 2
				singleNum := len([]rune(rightCommand)) - notSingleNum
				fmt.Print(string(bytes.Repeat([]byte("\b"), notSingleNum*2+singleNum)))
			} else {
				notSingleNum := (len(leftCommand) - len([]rune(leftCommand))) / 2
				singleNum := len([]rune(leftCommand)) - notSingleNum
				fmt.Print(string(bytes.Repeat([]byte("\b"), notSingleNum*2+singleNum)))
				fmt.Print("\033[K")
				if len([]rune(rightCommand)) > 1 {
					leftCommand = leftCommand + string([]rune(rightCommand)[:1])
					rightCommand = string([]rune(rightCommand)[1:])
				} else if len([]rune(rightCommand)) == 1 {
					leftCommand = leftCommand + string([]rune(rightCommand)[:1])
					rightCommand = ""
				}
				fmt.Print(leftCommand + rightCommand)
				notSingleNum = (len(rightCommand) - len([]rune(rightCommand))) / 2
				singleNum = len([]rune(rightCommand)) - notSingleNum
				fmt.Print(string(bytes.Repeat([]byte("\b"), notSingleNum*2+singleNum)))
			}
		} else if event.Key == keyboard.KeyTab {
			if len(rightCommand) != 0 || console.shellMode || console.sshMode {
				continue
			}
			task := &HelperTask{
				IsNodeMode: console.nodeMode,
				Uncomplete: leftCommand,
			}
			helper.TaskChan <- task
			compelete := <-helper.ResultChan
			if len(compelete) == 1 {
				fmt.Print("\r\033[K")
				fmt.Print(console.status)
				fmt.Print(compelete[0])
				leftCommand = compelete[0]
			} else if len(compelete) > 1 {
				fmt.Print("\r\n")
				for _, command := range compelete {
					fmt.Print(command + "    ")
				}
				fmt.Print("\r\n")
				fmt.Print(console.status)
				fmt.Print(leftCommand)
			}
		} else if event.Key == keyboard.KeyCtrlC {
			if !console.shellMode && !console.sshMode {
				printer.Warning("\r\n[*]Please use 'exit' to exit stowaway or use 'back' to return to parent panel")
			} else {
				printer.Warning("\r\n[*]Please use 'exit' to exit shell/sshmode")
			}
		} else {
			if !console.shellMode && !console.sshMode {
				fmt.Print("\r\033[K")
				fmt.Print(console.status)
				if event.Key == keyboard.KeySpace {
					leftCommand = leftCommand + " "
				} else {
					leftCommand = leftCommand + string(event.Rune)
				}
				fmt.Print(leftCommand + rightCommand)
				notSingleNum := (len(rightCommand) - len([]rune(rightCommand))) / 2
				singleNum := len([]rune(rightCommand)) - notSingleNum
				fmt.Print(string(bytes.Repeat([]byte("\b"), notSingleNum*2+singleNum)))
			} else {
				notSingleNum := (len(leftCommand) - len([]rune(leftCommand))) / 2
				singleNum := len([]rune(leftCommand)) - notSingleNum
				fmt.Print(string(bytes.Repeat([]byte("\b"), notSingleNum*2+singleNum)))
				fmt.Print("\033[K")
				if event.Key == keyboard.KeySpace {
					leftCommand = leftCommand + " "
				} else {
					leftCommand = leftCommand + string(event.Rune)
				}
				fmt.Print(leftCommand + rightCommand)
				notSingleNum = (len(rightCommand) - len([]rune(rightCommand))) / 2
				singleNum = len([]rune(rightCommand)) - notSingleNum
				fmt.Print(string(bytes.Repeat([]byte("\b"), notSingleNum*2+singleNum)))
			}
		}
	}
}