-
Notifications
You must be signed in to change notification settings - Fork 132
/
main.go
55 lines (46 loc) · 1 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
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package main
import (
"os"
"github.com/mitchellh/cli"
"github.com/hashicorp/terraform-ls/internal/cmd"
)
func main() {
c := &cli.CLI{
Name: "terraform-ls",
Version: VersionString(),
Args: os.Args[1:],
HelpWriter: os.Stdout,
}
ui := &cli.ColoredUi{
ErrorColor: cli.UiColorRed,
WarnColor: cli.UiColorYellow,
Ui: &cli.BasicUi{
Writer: os.Stdout,
Reader: os.Stdin,
ErrorWriter: os.Stderr,
},
}
c.Commands = map[string]cli.CommandFactory{
"serve": func() (cli.Command, error) {
return &cmd.ServeCommand{
Ui: ui,
Version: VersionString(),
AlgoliaAppID: algoliaAppID,
AlgoliaAPIKey: algoliaAPIKey,
}, nil
},
"version": func() (cli.Command, error) {
return &cmd.VersionCommand{
Ui: ui,
Version: VersionString(),
}, nil
},
}
exitStatus, err := c.Run()
if err != nil {
ui.Error("Error: " + err.Error())
}
os.Exit(exitStatus)
}