Documentation
¶
Index ¶
- func CreateCmdHistoryFile(dir string) bool
- func DeleteCmd(dir string, value string) int
- func OverwriteCmdHistoryFile(dir string, cmds []Command) bool
- func RunMockCommand(sc *ScheduledCommand, c chan int)
- func RunShellScriptCommand(sc *ScheduledCommand, c chan int)
- func RunShellScriptCommandWithSpinner(sc *ScheduledCommand, c chan int)
- func UpdateCommandDuration(dir string, cmd Command, duration time.Duration) bool
- func WriteCmdHistoryFile(dir string, cmd Command) bool
- type Command
- type ScheduledCommand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateCmdHistoryFile ¶
CreateCmdHistoryFile creates an empty history file
func DeleteCmd ¶
DeleteCmd deletes a command. It's best to pass in the commandHash because commands may look similar.
func OverwriteCmdHistoryFile ¶
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 ¶
UpdateCommandDuration updates a command with the same hash in the history file
func WriteCmdHistoryFile ¶
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 ¶
NewCommand creates a new Command struct and populates the fields
func ReadCmdHistoryFile ¶
ReadCmdHistoryFile reads historyFile and generates a list of Command structs
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).