utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SysVarPrintFormatKey string = "sys.printfmt"
)

Functions

func AskYesNo

func AskYesNo(msg string, def string) int

1 yes, 0 no, -1 return

func Bytes2StrLit

func Bytes2StrLit(b []byte) string

func Bytes2hex

func Bytes2hex(s []byte) string

func ContextWithProp

func ContextWithProp(ctx context.Context, p *properties.Properties) context.Context

func ExtractIshellContext

func ExtractIshellContext(ctx context.Context) *ishell.Context

func GetArgsAndOptionFlag

func GetArgsAndOptionFlag(rawArgs []string) ([]string, []string)

GetArgsAndOptionFlag returns args and option flag Example: ['arg1', 'arg2', '--option-a=value', '--option-b'] => {args: ['arg1', 'arg2'], optionFlag: ['--option-a=value', '--option-b']} ['arg1', '--option1', 'arg2', '--option2'] => {args: ['arg1', 'arg2'], optionFlag: ['--option1', '--option2']}

func GetStringLit

func GetStringLit(raw string) ([]byte, error)

func HasForceYes

func HasForceYes(ctx context.Context) bool

func Hexstr2bytes

func Hexstr2bytes(hexStr string) ([]byte, error)

func InitBuiltinVaribles

func InitBuiltinVaribles()

func IsStringLit

func IsStringLit(raw string) bool

func IsVar

func IsVar(s string) bool

func NextKey

func NextKey(k []byte) []byte

NextKey returns the next key in byte-order.

func OutputWithElapse

func OutputWithElapse(f func() error) error

func Print

func Print(a ...interface{})

func PrintGlobalVaribles

func PrintGlobalVaribles()

func PrintSysVaribles

func PrintSysVaribles()

func PrintTable

func PrintTable(data [][]string)

func PropFromContext

func PropFromContext(ctx context.Context) *properties.Properties

func SetOptByString

func SetOptByString(ss []string, props *properties.Properties) error

func SysVarGet

func SysVarGet(varname string) (string, bool)

func SysVarSet

func SysVarSet(varname, val string)

func VarGet

func VarGet(varname string) ([]byte, bool)

func VarSet

func VarSet(varname string, val []byte)

Types

type ProgressReader

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

func NewProgressReader

func NewProgressReader(r io.Reader, total int64) *ProgressReader

func OpenFileToProgressReader

func OpenFileToProgressReader(fname string) (*os.File, *ProgressReader, error)

func (*ProgressReader) Error

func (pr *ProgressReader) Error() error

func (*ProgressReader) GetProgress

func (pr *ProgressReader) GetProgress() float64

func (*ProgressReader) Read

func (pr *ProgressReader) Read(b []byte) (int, error)

type StrLitType

type StrLitType int

String Literal Parsing h'12332321' <---- Hex string

const (
	StrLitHex StrLitType = iota
	StrLitNormal
)

Jump to

Keyboard shortcuts

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