func findServerByName(name string) (*Server, error) {
	for _, s := range ListServers(false) {
		if s.Name == name {
			return s, nil
		}
	}
	return nil, errors.New("server not found")
}
findServerByName find server from config by server name
package core
import (
	"errors"
	"fmt"
	"os"
	"os/signal"
	"sort"
	"syscall"
	"github.com/olekukonko/tablewriter"
	"github.com/mritd/mmh/common"
)
func ListServers(serverSort bool) Servers {
	var servers Servers
	if serverSort {
		sort.Sort(basicConfig.Servers)
	}
	servers = append(servers, basicConfig.Servers...)
	if currentConfig.configPath != basicConfig.configPath {
		if serverSort {
			sort.Sort(currentConfig.Servers)
		}
		servers = append(servers, currentConfig.Servers...)
	}
	return servers
}
func PrintServers(serverSort bool) {
	table := tablewriter.NewWriter(os.Stdout)
	table.SetHeader([]string{"Name", "User", "Tags", "Address"})
	ss := ListServers(serverSort)
	for _, s := range ss {
		table.Append([]string{s.Name, s.User, fmt.Sprint(s.Tags), fmt.Sprintf("%s:%d", s.Address, s.Port)})
	}
	table.Render()
}
func PrintServerDetail(serverName string) {
	s, err := findServerByName(serverName)
	common.CheckAndExit(err)
	table := tablewriter.NewWriter(os.Stdout)
	table.Append([]string{"NAME", s.Name})
	table.Append([]string{"USER", s.User})
	table.Append([]string{"ADDR", fmt.Sprintf("%s:%d", s.Address, s.Port)})
	table.Append([]string{"PROXY", s.Proxy})
	table.Append([]string{"CONFIG", s.ConfigPath})
	table.Render()
}
func SingleLogin(name string) {
	s, err := findServerByName(name)
	common.CheckAndExit(err)
	var tmuxWinIndex, tmuxWinName string
	var tmuxAutoRename bool
	if common.Tmux() {
		tmuxWinIndex, tmuxWinName = common.TmuxWindowInfo()
		tmuxAutoRename = common.TmuxAutomaticRename()
		common.TmuxSetWindowName(tmuxWinIndex, s.Name)
		common.TmuxSetAutomaticRename(tmuxWinIndex, false)
	}
	sig := make(chan os.Signal, 1)
	signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM)
	go func() {
		<-sig
		if common.Tmux() {
			common.TmuxSetWindowName(tmuxWinIndex, tmuxWinName)
			common.TmuxSetAutomaticRename(tmuxWinIndex, tmuxAutoRename)
		}
		os.Exit(1)
	}()
	common.PrintErrWithPrefix("\n😱", s.Terminal())
	if common.Tmux() {
		common.TmuxSetWindowName(tmuxWinIndex, tmuxWinName)
		common.TmuxSetAutomaticRename(tmuxWinIndex, tmuxAutoRename)
	}
}