-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmain.go
More file actions
61 lines (51 loc) · 1.6 KB
/
Copy pathmain.go
File metadata and controls
61 lines (51 loc) · 1.6 KB
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
54
55
56
57
58
59
60
61
package main
import (
"context"
"os"
"path"
"strings"
"github.com/rs/zerolog/log"
"github.com/urfave/cli/v3"
"github.com/ekristen/distillery/pkg/common"
"github.com/ekristen/distillery/pkg/signals"
_ "github.com/ekristen/distillery/pkg/commands/clean"
_ "github.com/ekristen/distillery/pkg/commands/info"
_ "github.com/ekristen/distillery/pkg/commands/install"
_ "github.com/ekristen/distillery/pkg/commands/list"
_ "github.com/ekristen/distillery/pkg/commands/proof"
_ "github.com/ekristen/distillery/pkg/commands/run"
_ "github.com/ekristen/distillery/pkg/commands/uninstall"
)
func main() {
ctx := signals.SetupSignalContext()
defer func() {
if r := recover(); r != nil {
// Log panics and exit
if err, ok := r.(error); ok {
log.Error().Bool("fail", true).Err(err).Msgf("fatal error: %s", err.Error())
os.Exit(1)
}
panic(r)
}
}()
app := &cli.Command{
Name: path.Base(os.Args[0]),
Usage: `install any binary from ideally any source`,
Description: `install any binary from ideally any detectable source`,
Version: strings.TrimLeft(common.AppVersion.Summary, "v"),
Before: common.Before,
Flags: common.Flags(),
Commands: common.GetCommands(),
CommandNotFound: func(ctx context.Context, c *cli.Command, command string) {
log.Fatal().Msgf("command %s not found.", command)
},
EnableShellCompletion: true,
Authors: []any{
"Erik Kristensen <erik@erikkristensen.com>",
},
}
if err := app.Run(ctx, os.Args); err != nil {
log.Error().Bool("fail", true).Err(err).Msgf("command failed: %s", err.Error())
}
common.WaitForOutput()
}