utils

package
v0.0.0-...-a31944b Latest Latest
Warning

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

Go to latest
Published: May 13, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CRLF              = "\r\n"
	ClearPreviousLine = "\033[1A\033[K"
	Delimiter         = "==============================================================="
	WordsWelcome      = Delimiter + CRLF +
		"   へ     /|" + CRLF +
		"  /\7    ∠_/ " + CRLF +
		"  / │   / /" + CRLF +
		" │ Z _,< /   /�  │     �   /  〉   Y       /  /" + CRLF +
		" ●  ●  〈  /" + CRLF +
		" ()  へ    | \〈" + CRLF +
		"  > _  ィ  │ //" + CRLF +
		"  / へ   / <| \\" + CRLF +
		"  �_  (_/  │//" + CRLF +
		"  7       |/" + CRLF +
		"  >�r ̄ ̄r�_" + CRLF + Delimiter + CRLF
	WordsInfo            = "\x1b[33;40m Welcome %s. %s \x1b[0m" + CRLF
	WordsDone            = "\x1b[33;40m Goodbye. Good luck. \x1b[0m" + CRLF
	WordsNotFound        = "Command not found: %s" + CRLF
	WordsCommandError    = "Command exec wrong: %s" + CRLF
	WordsNotSupport      = "Sorry, command not support now: %s" + CRLF
	WordsSSHNotAvailable = "SSH not available: %s" + CRLF
	WordsSSHInfo         = "Remote addr is %s. " + CRLF + Delimiter + CRLF
	WordsSSHLoading      = "\x1b[33;40m The connection is being established, please wait. \x1b[0m" + CRLF
	WordsSSHDone         = CRLF + "\x1b[33;40m Connection closed. Please press Enter twice to continue. \x1b[0m" + CRLF
	WordsExecWrong       = "cmd.Run() failed with %s" + CRLF
)

Variables

This section is empty.

Functions

func CreateSSHSession

func CreateSSHSession(rw io.ReadWriter, host string, config *ssh.ClientConfig) (*ssh.Session, error)

func GetHelpDoc

func GetHelpDoc(commands map[string]string, crlf string) string

GetHelpDoc get help doc

Types

type Command

type Command struct {
	Name   string            // command
	Params map[string]string // args
	Peaces []string
}

func NewCommand

func NewCommand(input string) (c Command)

type LogStr

type LogStr string

func LogSprintf

func LogSprintf(format string, a ...interface{}) LogStr

LogSprintf format with time

func (LogStr) Bytes

func (s LogStr) Bytes() []byte

func (LogStr) S

func (s LogStr) S() string

type TermWrapper

type TermWrapper struct {
	// contains filtered or unexported fields
}

TermWrapper 封装 terminal 为一个 io.reader

func NewTermWrapper

func NewTermWrapper(channel ssh.Channel) *TermWrapper

func (*TermWrapper) Close

func (t *TermWrapper) Close() (err error)

func (*TermWrapper) Read

func (t *TermWrapper) Read(p []byte) (int, error)

func (*TermWrapper) Write

func (t *TermWrapper) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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