internal

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigPath

func ConfigPath(name string) string

func ConsoleRed added in v0.1.3

func ConsoleRed(txt string) string

ConsoleRed 控制台红色字符

func Execute

func Execute(args []string)

Types

type Command added in v0.1.3

type Command struct {
	// Match 用于匹配执行命令的正则表达式,可选
	// 如命令为 "git add ." 则,"add ." 会交给此正则来匹配
	// 若不匹配,当前这组命令将不会执行
	Match string

	// Cond 额外的执行条件,可选
	// 如:
	// go_module: 当前命令在 go module 里,即当前目录或者上级目录有 go.mod 文件
	// exec xx.sh : 执行 xx.sh 并执行成功
	// has_file app.toml: 当前目录或者上级目录有 app.toml 文件
	Cond []Condition

	// Cmd 命令,必填
	Cmd string

	Args []string

	// Timeout 超时时间,默认 1 分钟
	Timeout time.Duration

	Trace bool

	// AllowFail 是否允许执行失败,默认否
	// 默认情况下,当此命令执行失败后,后续命令也不会执行,程序将退出
	AllowFail bool
}

func (*Command) CanRun added in v0.1.4

func (c *Command) CanRun() bool

func (*Command) Exec added in v0.1.3

func (c *Command) Exec(ctx context.Context, env []string)

func (*Command) IsMatch added in v0.1.3

func (c *Command) IsMatch(str string) (bool, error)

type Condition added in v0.1.4

type Condition string

func (Condition) Allow added in v0.1.4

func (c Condition) Allow() bool

type Config

type Config struct {
	Rules []*Rule

	// Trace 是否调试模式,默认 true
	// 目前只控制是否打印过程日志
	Trace bool
	// contains filtered or unexported fields
}

func LoadConfig

func LoadConfig(name string) (*Config, error)

func (*Config) Format added in v0.1.1

func (c *Config) Format() error

func (*Config) Rule

func (c *Config) Rule() (*Rule, error)

type Rule

type Rule struct {
	Cmd  string
	Dir  []string
	Args []string
	Env  []string

	Pre   []*Command
	Post  []*Command
	Trace bool
}

func (*Rule) Format added in v0.1.1

func (r *Rule) Format() error

func (*Rule) Match

func (r *Rule) Match(wd string) int

func (*Rule) Run

func (r *Rule) Run(args []string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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