recmd

package module
v0.0.0-...-c8fe97f Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCmdHistoryFile

func CreateCmdHistoryFile(dir string) bool

CreateCmdHistoryFile creates an empty history file

func DeleteCmd

func DeleteCmd(dir string, value string) int

DeleteCmd deletes a command. It's best to pass in the commandHash because commands may look similar.

func OverwriteCmdHistoryFile

func OverwriteCmdHistoryFile(dir string, cmds []Command) bool

OverwriteCmdHistoryFile overwrites the history file with []Command passed in as a parameter

func RunMockCommand

func RunMockCommand(sc *ScheduledCommand, c chan int)

RunMockCommand runs a mock command

func RunShellScriptCommand

func RunShellScriptCommand(sc *ScheduledCommand, c chan int)

RunShellScriptCommand runs a command written to a temporary file

func RunShellScriptCommandWithSpinner

func RunShellScriptCommandWithSpinner(sc *ScheduledCommand, c chan int)

RunShellScriptCommandWithSpinner runs a command with a spinner

func UpdateCommandDuration

func UpdateCommandDuration(dir string, cmd Command, duration time.Duration) bool

UpdateCommandDuration updates a command with the same hash in the history file

func WriteCmdHistoryFile

func WriteCmdHistoryFile(dir string, cmd Command) bool

WriteCmdHistoryFile writes a command to the history file

Types

type Command

type Command struct {
	CmdHash   string        `json:"commandHash"`
	CmdString string        `json:"commandString"`
	Comment   string        `json:"comment"`
	Duration  time.Duration `json:"duration"`
}

Command represents a command and optionally a comment to document what the command does

func NewCommand

func NewCommand(cmdString string, cmdComment string) Command

NewCommand creates a new Command struct and populates the fields

func ReadCmdHistoryFile

func ReadCmdHistoryFile(dir string) ([]Command, error)

ReadCmdHistoryFile reads historyFile and generates a list of Command structs

func SelectCmd

func SelectCmd(dir string, value string) (Command, error)

SelectCmd returns a command

type ScheduledCommand

type ScheduledCommand struct {
	Command
	Coutput    string    `json:"coutput"`
	ExitStatus int       `json:"exitStatus"`
	StartTime  time.Time `json:"startTime"`
	EndTime    time.Time `json:"endTime"`
}

ScheduledCommand represents a command that is scheduled to run

func ScheduleCommand

func ScheduleCommand(cmd Command, f func(*ScheduledCommand, chan int)) ScheduledCommand

ScheduleCommand runs a Command based on a function passed in as the second parameter. This gives the ability to run Commands in multiple ways; for example, as a "mock" command (RunMockCommand) or a shell script command (RunShellScriptCommand).

Jump to

Keyboard shortcuts

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