func registerCommands(shell *ishell.Shell, conn *net.TCPConn) { shell.Register("set", func(args ...string) (string, error) { if len(args) < 2 { return "", errors.New("set <key> <value>") } requestType := gohash.Request_SET request := &gohash.Request{ Type: &requestType, Key: &args[0], Value: &args[1], } return rpc(conn, request), nil }) shell.Register("get", func(args ...string) (string, error) { if len(args) < 1 { return "", errors.New("get <key>") } requestType := gohash.Request_GET request := &gohash.Request{ Type: &requestType, Key: &args[0], } return rpc(conn, request), nil }) shell.Register("delete", func(args ...string) (string, error) { if len(args) < 1 { return "", errors.New("delete <key>") } requestType := gohash.Request_DELETE request := &gohash.Request{ Type: &requestType, Key: &args[0], } return rpc(conn, request), nil }) }
func doLogin(shell *ishell.Shell) { shell.ShowPrompt(false) defer shell.ShowPrompt(true) shell.Println("Let's simulate login") // prompt for input shell.Print("Username: "******"Password: "******"Your inputs were", username, "and", password+".") }