forked from DataDog/datadog-agent
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main_common.go
49 lines (42 loc) · 1.15 KB
/
main_common.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
//go:build linux || windows
// +build linux windows
package main
import (
"fmt"
"os"
"strings"
"github.com/StackVista/stackstate-agent/cmd/system-probe/app"
)
func subCommands() (commandNames []string) {
for _, command := range app.SysprobeCmd.Commands() {
commandNames = append(commandNames, append(command.Aliases, command.Name())...)
}
return
}
func setDefaultCommandIfNonePresent() {
args := []string{os.Args[0], "run"}
if len(os.Args) > 1 {
potentialCommand := os.Args[1]
if potentialCommand == "help" {
return
}
for _, command := range subCommands() {
if command == potentialCommand {
return
}
}
args = append(args, os.Args[1:]...)
}
os.Args = args
}
func checkForDeprecatedFlags() {
for i, a := range os.Args {
if strings.HasPrefix(a, "-config") {
fmt.Println("WARNING: `-config` argument is deprecated and will be removed in a future version. Please use `--config` instead.")
os.Args[i] = "-" + os.Args[i]
} else if strings.HasPrefix(a, "-pid") {
fmt.Println("WARNING: `-pid` argument is deprecated and will be removed in a future version. Please use `--pid` instead.")
os.Args[i] = "-" + os.Args[i]
}
}
}