internal

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "v0.0.3"

Variables

View Source
var Cfg = NewConfig()
View Source
var CommandSuggests = []prompt.Suggest{
	{Text: "-n", Description: "Displays the next page of the server list."},
	{Text: "-p", Description: "Displays the previous page of the server list."},
	{Text: "-g", Description: "Set the group for the server list."},
	{Text: "-h", Description: "Display the usage guide of J2."},
	{Text: "-exit", Description: "Exit J2."},
}
View Source
var DefaultConsoleParserWrapper = NewConsoleParserWrapper()
View Source
var KeyHandlers = map[prompt.Key]prompt.KeyBindFunc{
	prompt.Enter:    DoEnter,
	prompt.ControlM: DoEnter,
	prompt.ControlJ: DoEnter,
	prompt.PageUp:   DoPrevPage,
	prompt.PageDown: DoNextPage,
	prompt.Home:     DoFirstPage,
	prompt.End:      DoLastPage,
}

Functions

func CheckAndPrintUsageGuide added in v0.0.3

func CheckAndPrintUsageGuide()

func CheckAndPrintVersion

func CheckAndPrintVersion()

func ClearScreen

func ClearScreen()

func Completer

func Completer(doc prompt.Document) []prompt.Suggest

func Connect

func Connect(s *Server) error

func DoEnter

func DoEnter(*prompt.Buffer)

func DoFirstPage added in v0.0.2

func DoFirstPage(*prompt.Buffer)

func DoLastPage added in v0.0.2

func DoLastPage(*prompt.Buffer)

func DoMakeLivePrefix

func DoMakeLivePrefix() (string, bool)

func DoNextPage added in v0.0.2

func DoNextPage(*prompt.Buffer)

func DoPrevPage added in v0.0.2

func DoPrevPage(*prompt.Buffer)

func Echo

func Echo(format string, args ...interface{})

func EchoAndExit

func EchoAndExit(format string, args ...interface{})

func Error

func Error(format string, args ...interface{})

func ErrorAndExit

func ErrorAndExit(format string, args ...interface{})

func Executor

func Executor(input string)

func Exit added in v0.0.3

func Exit(n int)

func NewConsoleParserWrapper added in v0.0.3

func NewConsoleParserWrapper() prompt.ConsoleParser

func Options

func Options() []prompt.Option

func Reset added in v0.0.3

func Reset()

func ShowTitle

func ShowTitle()

func ShowUsageGuide

func ShowUsageGuide()

Types

type Config

type Config struct {
	PageSize   int       `yaml:"pageSize"`   // 每页显示多少个服务器(默认10)
	SortBy     string    `yaml:"sortBy"`     // 排序方式(name, host, disable)
	AutoClear  bool      `yaml:"autoClear"`  // 自动清屏
	PrivateKey string    `yaml:"privateKey"` // 全局的私钥路径(可被服务器设置覆盖)
	Password   string    `yaml:"password"`   // 全局的登录密码(可被服务器设置覆盖)
	Servers    []*Server `yaml:"servers"`    // 远程服务器列表

	Auth  ssh.AuthMethod `yaml:"-"`
	Page  int            `yaml:"-"`
	Group string         `yaml:"-"`
}

func NewConfig

func NewConfig() *Config

func (*Config) AllList

func (c *Config) AllList() []*Server

func (*Config) Init

func (c *Config) Init() error

func (*Config) NextPage

func (c *Config) NextPage()

func (*Config) PageList

func (c *Config) PageList() []*Server

func (*Config) PrevPage

func (c *Config) PrevPage()

func (*Config) ShowSummary

func (c *Config) ShowSummary()

func (*Config) Summary

func (c *Config) Summary(list []*Server) []string

type ConsoleParserWrapper added in v0.0.3

type ConsoleParserWrapper struct {
	prompt.ConsoleParser
	// contains filtered or unexported fields
}

func (*ConsoleParserWrapper) Setup added in v0.0.3

func (w *ConsoleParserWrapper) Setup() error

func (*ConsoleParserWrapper) TearDown added in v0.0.3

func (w *ConsoleParserWrapper) TearDown() error

type Server

type Server struct {
	Name       string `yaml:"name"`       // 名称(可被用于搜索和快速连接)
	User       string `yaml:"user"`       // 登录用户名
	Host       string `yaml:"host"`       // 登录主机名或IP地址
	Port       int    `yaml:"port"`       // 登录端口(默认22)
	PrivateKey string `yaml:"privateKey"` // 私钥路径(为空时不适用)
	Password   string `yaml:"password"`   // 登录密码(私钥登录优先,没有私钥则使用密码)
	Desc       string `yaml:"desc"`       // 简短的描述
	Group      string `yaml:"group"`      // 分组

	Auth ssh.AuthMethod `yaml:"-"`
	Addr string         `yaml:"-"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL