syscmd

package
v0.0.0-...-9c55465 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SearchExeCmd = &gcli.Command{
	Name:    "find-bin",
	Aliases: []string{"find-exe", "search"},
	Desc:    "search executable file in system PATH",
	Config: func(c *gcli.Command) {
		c.AddArg("keyword", "keywords for search in PATH dirs", true)
	},
	Func: func(c *gcli.Command, _ []string) error {
		files := sysutil.SearchPath(c.Arg("keyword").String(), 10)

		show.AList("Matched exe files:", files)
		return nil
	},
}

SearchExeCmd command

View Source
var SysCmd = &gcli.Command{
	Name:    "sys",
	Aliases: []string{"os", "system"},
	Desc:    "provide some useful system commands",
	Subs: []*gcli.Command{
		SearchExeCmd,
		WhichExeCmd,
		SysInfoCmd,
		NewQuickOpenCmd(),
		NewBatchRunCmd(),
		NewEnvInfoCmd(),
		NewClipboardCmd(),
	},
}

SysCmd command

View Source
var SysInfoCmd = &gcli.Command{
	Name: "info",

	Desc: "display current operation system information",
	Config: func(c *gcli.Command) {

	},
	Func: func(c *gcli.Command, _ []string) error {
		info := map[string]any{
			"os platform": runtime.GOOS,
			"os arch":     runtime.GOARCH,
		}

		if sysutil.IsWindows() {
			if sysutil.IsMSys() {
				info["hosts file1"] = "/etc/hosts"
				info["hosts file"] = "/c/Windows/System32/drivers/etc/hosts"
			} else {
				info["hosts file"] = "C:\\Windows\\System32\\drivers\\etc\\hosts"
			}
		} else {
			info["hosts file"] = "/etc/hosts"
		}

		show.AList("System info:", info)
		return nil
	},
}

SysInfoCmd command

View Source
var WhichExeCmd = &gcli.Command{
	Name:    "which",
	Aliases: []string{"whereis", "type"},
	Desc:    "show full path for the executable name",
	Config: func(c *gcli.Command) {
		c.AddArg("name", "executable name for match", true)
	},
	Func: func(c *gcli.Command, _ []string) error {
		name := c.Arg("name").String()
		file, err := sysutil.Executable(name)
		if err != nil {
			return err
		}

		fmt.Println(file)
		return nil
	},
}

WhichExeCmd command

Functions

func NewBatchRunCmd

func NewBatchRunCmd() *gcli.Command

NewBatchRunCmd instance

func NewClipboardCmd

func NewClipboardCmd() *gcli.Command

NewClipboardCmd command

func NewEnvInfoCmd

func NewEnvInfoCmd() *gcli.Command

NewEnvInfoCmd instance

func NewQuickOpenCmd

func NewQuickOpenCmd() *gcli.Command

NewQuickOpenCmd command

Types

This section is empty.

Jump to

Keyboard shortcuts

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