-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
73 lines (64 loc) · 1.74 KB
/
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"context"
"embed"
"fmt"
"log"
"os"
"strings"
"github.com/3lvia/cli/pkg/build"
"github.com/3lvia/cli/pkg/create"
"github.com/3lvia/cli/pkg/deploy"
"github.com/3lvia/cli/pkg/githubactions"
"github.com/3lvia/cli/pkg/initialize"
"github.com/3lvia/cli/pkg/run"
"github.com/3lvia/cli/pkg/scan"
"github.com/3lvia/cli/pkg/shared"
"github.com/3lvia/cli/pkg/style"
"github.com/3lvia/cli/pkg/upgrade"
"github.com/urfave/cli/v3"
)
//go:embed VERSION
var version embed.FS
func main() {
log.SetFlags(0)
versionFile, err := version.ReadFile("VERSION")
if err != nil {
log.Fatal(err)
}
version := strings.TrimSpace(string(versionFile))
// Check for a new version of the CLI after all these commands.
// Any new commands should be added here.
commands := shared.WithCheckVersionAfterCommands(
[]*cli.Command{
build.Command(),
deploy.Command(),
run.Command(),
scan.Command(),
githubactions.Command(),
create.Command(),
initialize.Command(),
},
version,
)
app := &cli.Command{
Name: "3lv",
Usage: "Command Line Interface tool for creating, building and securing Elvia applications ⚡",
Version: version,
EnableShellCompletion: true,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "non-interactive",
Usage: "Run in non-interactive mode. Accepts all default values without prompting for confirmation.",
Sources: cli.EnvVars("3LV_NON_INTERACTIVE"),
},
},
// Don't check for updates when running the upgrade command.
// Doesn't need config either.
Commands: append(commands, upgrade.Command(version)),
}
ctx := context.Background()
if err := app.Run(ctx, os.Args); err != nil {
style.PrintError(fmt.Sprintf("\n\nERROR: %s", err))
}
}