mygo

package module
v0.0.0-...-770e773 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: GPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileExist

func FileExist(filename string) bool

func FileMode

func FileMode(filename string) fs.FileMode

func FileSize

func FileSize(filename string) (bool, int64)

func GuessUTF8File

func GuessUTF8File(filename string) bool

func HomeFile

func HomeFile(filename string) string

func IgnoreFile

func IgnoreFile(filename string) bool

func IsDir

func IsDir(filename string) bool
func IsSymlink(filename string) bool

func ParseFlag

func ParseFlag(args ...string)

ParseFlag specifies non-flag args. Ex. ParseFlag("required_arg0", "[optional_arg1]") Optional args must appear after required args.

func ReadLastLink(name string) string

func RunOpMapCmd

func RunOpMapCmd[T any]()

RunOpMapCmd is a helper that combines BuildOpMap and RunCmd

func Yorn

func Yorn(s string, args ...any)

Types

type Cmd

type Cmd struct {
	C *exec.Cmd
	// contains filtered or unexported fields
}

func NewCmd

func NewCmd(name string, args ...string) Cmd

func (Cmd) IgnoreErr

func (c Cmd) IgnoreErr(ignoreErr bool) Cmd

func (Cmd) Interactive

func (c Cmd) Interactive()

func (Cmd) Run

func (c Cmd) Run()

func (Cmd) RunWithExitCode

func (c Cmd) RunWithExitCode() int

func (Cmd) Silent

func (c Cmd) Silent(silent bool) Cmd

func (Cmd) Start

func (c Cmd) Start() *os.Process

func (Cmd) Stdout

func (c Cmd) Stdout() []byte

func (Cmd) Trace

func (c Cmd) Trace() Cmd

type OP

type OP struct {
	Alias string
	Name  string
	Fn    func()
}

type OPMap

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

func BuildOPMap

func BuildOPMap[T any]() OPMap

BuildOPMap extracts exported methods of opRecv to a map, so that the methods can be called by the name or alias. An example opRecv is,

type GitOP struct {}
func (op GitOP) CM_Commit() {...}
func (op GitOP) Status() {...}

BuildOPMap[GitOP]() returns an OPMap,

{
    "cm": OP{Alias: "cm", Name: "commit", Fn: wrapper_of_GitOP.CM_Commit,
    "status": OP{Alias: "status", Name: "status", Fn: wrapper_of_GitOP.Status,
}

then we can call the op by alias,

var gitop OPMap = BuildOPMap[GitOP]()
gitop.Run("cm")

we can add additional methods manually to OPMap,

gitop.Add("log", gitLog)

func (OPMap) Add

func (om OPMap) Add(alias string, fn func())

func (OPMap) Run

func (om OPMap) Run(alias string)

func (OPMap) RunCmd

func (om OPMap) RunCmd()

Jump to

Keyboard shortcuts

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