-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
30 lines (25 loc) · 770 Bytes
/
main.go
File metadata and controls
30 lines (25 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package main
import (
"os"
"github.com/main-branch/chezroot/internal/executor"
)
// run is an extraction of main logic for testability. It returns the exit code
// that should be used by the process. Any error from ExecuteChezmoi is mapped
// to exit code 1 after writing its message to stderr.
func run(args []string) int {
exitCode, err := executor.ExecuteChezmoi(args, false)
if err != nil {
os.Stderr.WriteString(err.Error() + "\n")
return 1
}
return exitCode
}
// exitFunc is a hook to allow tests to intercept process exit without terminating
// the test binary. It defaults to os.Exit.
var exitFunc = os.Exit
func main() {
// Get command line arguments (excluding the program name itself)
args := os.Args[1:]
code := run(args)
exitFunc(code)
}