-
-
Notifications
You must be signed in to change notification settings - Fork 86
/
docs.go
47 lines (39 loc) 路 987 Bytes
/
docs.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
package cmd
import (
"fmt"
"os/exec"
"runtime"
"github.com/spf13/cobra"
u "github.com/cloudposse/atmos/pkg/utils"
)
const (
atmosDocsURL = "https://atmos.tools"
)
// docsCmd opens the Atmos docs
var docsCmd = &cobra.Command{
Use: "docs",
Short: "Open the Atmos docs",
Long: `This command opens the Atmos docs`,
Example: "atmos docs",
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
Run: func(cmd *cobra.Command, args []string) {
var err error
os := runtime.GOOS
switch os {
case "linux":
err = exec.Command("xdg-open", atmosDocsURL).Start()
case "windows":
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", atmosDocsURL).Start()
case "darwin":
err = exec.Command("open", atmosDocsURL).Start()
default:
err = fmt.Errorf("unsupported platform: %s", os)
}
if err != nil {
u.LogErrorAndExit(err)
}
},
}
func init() {
RootCmd.AddCommand(docsCmd)
}