extcmd

package
v0.0.0-...-a91fe3a Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ListUserCmd = &gcli.Command{
	Name:    "list",
	Desc:    "list all added user commands",
	Aliases: []string{"ls", "l"},
}
View Source
var PlugCmd = &gcli.Command{
	Name:   "plug",
	Hidden: true,
	Desc:   "manage and run kite plugins(powered by traefik/yaegi interpreter)",
	Subs:   []*gcli.Command{},
	Config: func(c *gcli.Command) {
		c.AddArg("name", "input plugin name or path for execute")
	},
	Func: func(c *gcli.Command, args []string) error {
		name := c.Arg("name").String()
		if len(name) == 0 {
			return c.ShowHelp()
		}

		i := interp.New(interp.Options{
			GoPath: envutil.Getenv("GOPATH"),
		})
		if err := i.Use(stdlib.Symbols); err != nil {
			return err
		}

		fPath := apputil.ResolvePath(name)

		v, err := i.EvalPath(fPath)
		if err != nil {
			return err
		}

		dump.P(v.Interface())
		return nil
	},
}

PlugCmd for kite plugins

View Source
var TaskInfo = &gcli.Command{
	Name: "info",
	Desc: "show an Task information",
}
View Source
var TaskList = &gcli.Command{
	Name:    "list",
	Desc:    "list all Tasks",
	Aliases: []string{"ls", "l"},
}
View Source
var TaskManageCmd = &gcli.Command{
	Name:    "task",
	Desc:    "Task/Script run and management command",
	Aliases: []string{"scripts", "script"},
	Subs: []*gcli.Command{
		TaskList,
		TaskInfo,
		TaskRun,
	},
	Config: func(c *gcli.Command) {

	},
	Func: func(c *gcli.Command, args []string) error {
		return nil
	},
}

TaskManageCmd instance

View Source
var TaskRun = &gcli.Command{
	Name: "run",
	Desc: "run an Task",
}
View Source
var UserExtCmd = &gcli.Command{
	Name:    "xcmd",
	Aliases: []string{"ucmd"},
	Desc:    "manage and execute user extension commands",
	Subs: []*gcli.Command{
		ListUserCmd,
	},
	Config: func(c *gcli.Command) {
		c.BoolOpt2(&ueOpts.list, "list, ls", "display all user extra commands")
		c.StrOpt2(&ueOpts.info, "info, show, i", "display info for the input command")

		c.AddArg("command", "input command for execute")
	},
	Func: func(c *gcli.Command, args []string) error {

		name := c.Arg("command").String()
		if len(name) == 0 {
			return c.NewErr("please input command name for handle")
		}

		return nil
	},
}

UserExtCmd instance

Functions

This section is empty.

Types

type CmdAction

type CmdAction struct {
	Name    string   `json:"name"`
	Desc    string   `json:"desc"`
	User    string   `json:"user"`
	Workdir string   `json:"workdir"`
	Cmds    []string `json:"cmds"`
}

CmdAction struct

type CmdGroup

type CmdGroup struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	Author  string `json:"author"`
	// Description message
	Description string `json:"description"`
	// DefaultAction on run
	DefaultAction string `json:"default_action"`
	Context       struct {
		Workdir string `json:"workdir"`
	} `json:"context"`
	Actions map[string]*CmdAction `json:"actions"`
}

CmdGroup struct

type ExtraCmds

type ExtraCmds struct {
	maputil.Aliases
	// MetaDir path for load CmdGroup
	MetaDir string `json:"meta_dir"`
	// contains filtered or unexported fields
}

ExtraCmds config as command

func (*ExtraCmds) Info

func (ec *ExtraCmds) Info(name string)

func (*ExtraCmds) Init

func (ec *ExtraCmds) Init() error

func (*ExtraCmds) List

func (ec *ExtraCmds) List(name string)

func (*ExtraCmds) Run

func (ec *ExtraCmds) Run(args []string)

Jump to

Keyboard shortcuts

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