shell

package module
v0.22.3 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: GPL-3.0 Imports: 19 Imported by: 2

README

shell

A way to execute simple commands in a 'shell-like' way

This should correctly capture stdout and stderr in a non-blocking unbuffered way

install

go get -v -t -u go.wit.com/lib/gui/shell

License

The same License as GO itself

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorArgvEmpty error = errors.New("command was empty")
View Source
var FileMap map[string]*File
View Source
var INFO *log.LogFlag
View Source
var NOW *log.LogFlag
View Source
var RUN *log.LogFlag
View Source
var SSH *log.LogFlag

Functions

func Cat

func Cat(filename string) string

Cat a file into a string

func Chomp

func Chomp(a interface{}) string

TODO: fix this to chomp \n \r NULL \t and ' '

func Daemon

func Daemon(cmdline string, timeout time.Duration) int

func Dir

func Dir(dirname string) bool

return true if the filename exists (cross-platform)

func Exec

func Exec(cmdline string)

run something and never return from it TODO: pass STDOUT, STDERR, STDIN correctly TODO: figure out how to nohup the process and exit

func Execname

func Execname(filename string) string

func Exists

func Exists(filename string) bool

return true if the filename exists (cross-platform)

func GetComm

func GetComm(pid int) (string, error)

get comm from proc

func GetPPID

func GetPPID(pid int) (int, error)

get your parent PID

func InitCallback

func InitCallback(f func(interface{}, int))

func Int

func Int(s string) int

func Int64

func Int64(s string) int64

func IsDir

func IsDir(dirname string) bool

func Md5sum

func Md5sum(filename string) string

hash thyself: hash_file_md5(os.Args[0])

func Mkdir

func Mkdir(dir string) bool

makes the directory

func NewRun

func NewRun(workingpath string, cmd []string) error

func OpenBrowser

func OpenBrowser(url string) error

openBrowser opens the specified URL in the default browser of the user.

func Path

func Path(filename string) string

func Quiet

func Quiet(q bool)

this means it won't copy all the output to STDOUT

func RM

func RM(filename string)

func RemoveFirstElement

func RemoveFirstElement(slice []string) (string, []string)

this is stuff from a long time ago that there must be a replacement for

func Run

func Run(args []string) bool

func RunCmd

func RunCmd(workingpath string, parts []string) (error, bool, string)

send the path and the command

func RunCmdRun

func RunCmdRun(workingpath string, parts []string) error

send the path and the command

func RunString

func RunString(args string) bool

var newfile *shell.File

func Script

func Script(cmds string) int

func SetDelayInMsec

func SetDelayInMsec(msecs int)

func SetStderr

func SetStderr(newerr *os.File)

func SetStdout

func SetStdout(newout *os.File)

func Shell

func Shell() string

returns a string of the shell the user is using

func SpewOn

func SpewOn()

func Terminal

func Terminal() string

returns a string of the xterm the user is using for example, "xterm" or "mate-terminal"

func TestTerminalColor

func TestTerminalColor()

what genius figured this out? originally from github.com/dimasma0305/GoFetch

func Unlink(filename string)

func Wget

func Wget(url string) *bytes.Buffer

func WgetToFile

func WgetToFile(filepath string, url string) error

func Write

func Write(filepath string, data string) bool

write out a file. Always be nice and end with '\n' if you are here and want to complain about ending in '\n' then you probably aren't going to like lots of things in this package. I will quote the evilwm man page:

BUGS: The author's idea of friendly may differ to that of many other people.

func XtermCmd

func XtermCmd(path string, cmd []string)

spawns an xterm with something you can run at a command line

func XtermCmdBash

func XtermCmdBash(path string, cmd []string)

spawns an xterm with something you can run at a command line then executes bash

func XtermCmdWait

func XtermCmdWait(path string, cmd []string)

runs an xterm waits until xterm exits

Types

type File

type File struct {
	Name string
	// BufferSize	int
	// Buffer		*bytes.Buffer
	// Fbytes		[]byte
	TotalCount int
	Empty      bool
	Dead       bool

	Fio    io.ReadCloser // := process.StdoutPipe()
	Fbufio *bufio.Reader // := bufio.NewReader(pOUT)

}

type OldShell

type OldShell struct {
	Cmdline string
	Process *exec.Cmd
	Done    bool
	Quiet   bool
	Fail    bool
	Error   error
	Buffer  *bytes.Buffer

	// which names are really better here?
	// for now I init them both to test out
	// how the code looks and feels
	STDOUT *File
	STDERR *File
	Stdout *File
	Stderr *File
}

early code playground

func New

func New() *OldShell

default values for OldShell

type RunResult

type RunResult struct {
	Ok     bool
	Argv   []string
	Path   string
	Output []byte
	Err    error
	Outerr error
}

func Output added in v0.22.3

func Output(path string, args []string) *RunResult

run, but set the working path

func RunPath

func RunPath(path string, args []string) *RunResult

run, but set the working path

Jump to

Keyboard shortcuts

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