Version: v0.0.0-...-3c53a7c Latest Latest

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

Go to latest
Published: May 15, 2021 License: MIT Imports: 15 Imported by: 33


tools 命令行程序工具库




This section is empty.


View Source
var ErrGoEnvEmpty = errors.New("Go path env is empty.Please set GOPATH env in yonr shell config.")
View Source
var ErrUserCanceled = errors.New("error user canceled")
View Source
var NewLibNotFoundError = func(lib string) error {
	return fmt.Errorf(" \"%s\" not found.\nYou should use \"go get -u %s\" to install", lib, lib)


func CopyIfNotExist

func CopyIfNotExist(src string, target ...string) error

func ErrorIfInt64FieldNotInRange

func ErrorIfInt64FieldNotInRange(filename string, value int64, min int64, max int64) error

func ErrorIfIntFieldNotInRange

func ErrorIfIntFieldNotInRange(filename string, value int, min int, max int) error

func ErrorIfStringFieldNotInList

func ErrorIfStringFieldNotInList(filename string, value string, valuelist ...string) error

func FileExists

func FileExists(pathlist ...string) (bool, error)

func FindLib

func FindLib(gopathenv string, libname string) (string, error)

func IsFolder

func IsFolder(pathlist ...string) (bool, error)

func ReplaceLine

func ReplaceLine(path string, from string, to string) (bool, error)


type Answer

type Answer struct {
	Key   string
	Label string
	Value interface{}

func NewAnswer

func NewAnswer() *Answer

func (*Answer) Println

func (a *Answer) Println(w io.Writer, defaultKey string)

type Question

type Question struct {
	Description string
	Answers     []*Answer
	DefaultKey  string

func NewQuestion

func NewQuestion() *Question

func NewTrueOrFalseQuestion

func NewTrueOrFalseQuestion(desc string) *Question

func (*Question) AddAnswer

func (q *Question) AddAnswer(key string, label string, value interface{}) *Question

func (*Question) ExecIf

func (q *Question) ExecIf(a *app.Application, conditon bool, result interface{}) error

func (*Question) SetDefaultKey

func (q *Question) SetDefaultKey(k string) *Question

func (*Question) SetDescription

func (q *Question) SetDescription(d string) *Question

type Task

type Task struct {
	SrcFolder    string
	TargetFolder string
	Files        map[string][]byte
	Jobs         []func() error

func NewTask

func NewTask(srcfolder string, targetfolder string) *Task

func (*Task) AddJob

func (t *Task) AddJob(jobs ...func() error)

func (*Task) ConfirmIf

func (t *Task) ConfirmIf(a *app.Application, conditon bool) (bool, error)

func (*Task) Copy

func (t *Task) Copy(src string, target string) error

func (*Task) CopyFiles

func (t *Task) CopyFiles(files map[string]string) error

func (*Task) ErrosIfAnyFileExists

func (t *Task) ErrosIfAnyFileExists() error

func (*Task) ErrosIfAnyFileNotExists

func (t *Task) ErrosIfAnyFileNotExists() error

func (*Task) Exec

func (t *Task) Exec() error

func (*Task) ListFiles

func (t *Task) ListFiles() []string

func (*Task) Render

func (t *Task) Render(src string, target string, data interface{}) error

func (*Task) RenderFiles

func (t *Task) RenderFiles(files map[string]string, data interface{}) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL