-
Notifications
You must be signed in to change notification settings - Fork 66
/
main.go
88 lines (77 loc) · 2.63 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//go:generate goversioninfo -o=resource_windows.syso
package main
import (
"os"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
// Commands
"github.com/newrelic/newrelic-cli/internal/agent"
"github.com/newrelic/newrelic-cli/internal/apiaccess"
"github.com/newrelic/newrelic-cli/internal/apm"
"github.com/newrelic/newrelic-cli/internal/cli"
"github.com/newrelic/newrelic-cli/internal/config"
configAPI "github.com/newrelic/newrelic-cli/internal/config/api"
configCmd "github.com/newrelic/newrelic-cli/internal/config/command"
"github.com/newrelic/newrelic-cli/internal/decode"
diagnose "github.com/newrelic/newrelic-cli/internal/diagnose"
"github.com/newrelic/newrelic-cli/internal/edge"
"github.com/newrelic/newrelic-cli/internal/entities"
"github.com/newrelic/newrelic-cli/internal/events"
"github.com/newrelic/newrelic-cli/internal/install"
"github.com/newrelic/newrelic-cli/internal/nerdgraph"
"github.com/newrelic/newrelic-cli/internal/nerdstorage"
"github.com/newrelic/newrelic-cli/internal/nrql"
"github.com/newrelic/newrelic-cli/internal/profile"
"github.com/newrelic/newrelic-cli/internal/reporting"
"github.com/newrelic/newrelic-cli/internal/synthetics"
"github.com/newrelic/newrelic-cli/internal/utils"
"github.com/newrelic/newrelic-cli/internal/workload"
)
var (
appName = "newrelic-dev"
)
func init() {
// Bind imported sub-commands
Command.AddCommand(agent.Command)
Command.AddCommand(apiaccess.Command)
Command.AddCommand(synthetics.Command)
Command.AddCommand(apm.Command)
Command.AddCommand(configCmd.Command)
Command.AddCommand(decode.Command)
Command.AddCommand(diagnose.Command)
Command.AddCommand(edge.Command)
Command.AddCommand(entities.Command)
Command.AddCommand(events.Command)
Command.AddCommand(install.Command)
Command.AddCommand(nerdgraph.Command)
Command.AddCommand(nerdstorage.Command)
Command.AddCommand(nrql.Command)
Command.AddCommand(profile.Command)
Command.AddCommand(reporting.Command)
Command.AddCommand(utils.Command)
Command.AddCommand(workload.Command)
CheckPrereleaseMode(Command)
os.Setenv("NEW_RELIC_CLI_VERSION", cli.Version())
}
func main() {
if err := Execute(); err != nil {
if err != flag.ErrHelp {
log.Fatal(err)
}
}
}
// CheckPrereleaseMode unhides subcommands marked as hidden when the pre-release
// flag is active.
func CheckPrereleaseMode(c *cobra.Command) {
if configAPI.GetConfigTernary(config.PreReleaseFeatures).Bool() {
return
}
log.Debug("Pre-release mode active")
for _, cmd := range c.Commands() {
if cmd.Hidden {
log.Debugf("Activating pre-release subcommand: %s", cmd.Name())
cmd.Hidden = false
}
}
}