gosh

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 7 Imported by: 0

README

gosh

Gosh is a library of simple helpers that make using go as a scripting language for quick system automation much more convenient.

It helps with things like these:

import (
	sh "github.com/ljanyst/gosh"
)

func setupCommonLisp() {
	sh.Must(sh.Run("rm", "-rf", sh.Expand("~/Apps/common-lisp")))
	sh.Must(sh.RunS("sbcl --noinform --load setup-files/quicklisp.lisp --load setup-files/install-quicklisp.lisp"))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expand

func Expand(path string) string

Replace ~ with the home directory of the current user

func FileExists

func FileExists(file string) bool

Check if the file exists

func Must

func Must(err error)

If error is not nil, print it and exit

func Run

func Run(args ...string) error

Run a command in shell

func RunIn

func RunIn(path string, args ...string) error

Run a command in shell in a directory

func RunInS

func RunInS(path, command string) error

Run a command in shell in a directory

func RunS

func RunS(command string) error

Run a command in shell

func SetupLogging

func SetupLogging(level string)

Set logging up, valid levels are: Trace, Debug, Info, Warn, Error, Fatal, Panic

func SuRun

func SuRun(args ...string) error

Run a command in shell as root

func SuRunIn

func SuRunIn(path string, args ...string) error

Run a command in shell in a directory as root

func SuRunInS

func SuRunInS(path, command string) error

Run a command in shell in a directory

func SuRunS

func SuRunS(command string) error

Run a command in shell as root

func UserName

func UserName() string

Get the username of the current user

Types

type StringFlags

type StringFlags []string

A helper from collecting string flags into an array

func (*StringFlags) Set

func (sf *StringFlags) Set(value string) error

func (*StringFlags) String

func (sf *StringFlags) String() string

Jump to

Keyboard shortcuts

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