aboutsummaryrefslogtreecommitdiffsponsor
path: root/internal/exec.go
blob: 6ed3e5cb349631196c9177cdd726c4f64d784469 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
}