-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (44 loc) · 942 Bytes
/
main.go
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-FileCopyrightText: Stefan Tatschner
//
// SPDX-License-Identifier: MIT
package main
import (
"errors"
"fmt"
"os"
"github.com/alecthomas/kong"
"github.com/alecthomas/kong-toml"
"github.com/rumpelsepp/penrun/internal"
)
func main() {
var (
config penrun.Config
ctx *kong.Context
)
cwd, err := os.Getwd()
if err != nil {
fmt.Fprintln(os.Stderr, err)
// TODO: Use exit codes from FreeBSD
os.Exit(1)
}
configPath, err := penrun.FindConfigFile(cwd)
if err != nil {
if !errors.Is(err, os.ErrNotExist) {
fmt.Fprintln(os.Stderr, err)
// TODO: Use exit codes from FreeBSD
os.Exit(1)
}
}
if configPath != "" {
ctx = kong.Parse(&config, kong.Configuration(kongtoml.Loader, configPath))
} else {
ctx = kong.Parse(&config)
}
fr, err := penrun.RunCommand(&config)
if err != nil {
fmt.Fprintln(os.Stderr, err)
// TODO: Use exit codes from FreeBSD
ctx.Exit(1)
}
os.Exit(fr.ExitCode)
}