diff options
author | Slack Coder <slackcoder@server.ky> | 2024-10-15 10:35:09 -0500 |
---|---|---|
committer | Slack Coder <slackcoder@server.ky> | 2024-10-16 16:59:13 -0500 |
commit | 097f8670eb2e5c49a36dcf399e59f4057007b5b1 (patch) | |
tree | 5974de5c318b8783947eb14ee0f542a064f66f54 /internal/exec.go | |
parent | 8ca5da1434c7ad1cc2e23e9d8a08d15b14382ebc (diff) | |
download | mirror-097f8670eb2e5c49a36dcf399e59f4057007b5b1.tar.xz |
Fail immediately when commands missing
Diffstat (limited to 'internal/exec.go')
-rw-r--r-- | internal/exec.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/exec.go b/internal/exec.go new file mode 100644 index 0000000..6ed3e5c --- /dev/null +++ b/internal/exec.go @@ -0,0 +1,21 @@ +package internal + +import ( + "fmt" + "os/exec" +) + +type CommandNotFound string + +func (e CommandNotFound) Error() string { + return fmt.Sprintf("command '%s' is missing and must be present for operation", string(e)) +} + +func RequireCommand(cmd string) error { + _, err := exec.LookPath(cmd) + if err != nil { + return CommandNotFound(cmd) + } + + return nil +} |