-
Notifications
You must be signed in to change notification settings - Fork 335
/
main.go
39 lines (33 loc) · 988 Bytes
/
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
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Program gops is a tool to list currently running Go processes.
package main
import (
"log"
"os"
"strconv"
"github.com/google/gops/internal/cmd"
)
func main() {
var root = cmd.NewRoot()
root.AddCommand(cmd.ProcessCommand())
root.AddCommand(cmd.TreeCommand())
root.AddCommand(cmd.AgentCommands()...)
// Legacy support for `gops <pid>` command.
//
// When the second argument is provided as int as opposed to a sub-command
// (like proc, version, etc), gops command effectively shortcuts that
// to `gops process <pid>`.
if len(os.Args) > 1 {
// See second argument appears to be a pid rather than a subcommand
_, err := strconv.Atoi(os.Args[1])
if err == nil {
cmd.ProcessInfo(os.Args[1:]) // shift off the command name
return
}
}
if err := root.Execute(); err != nil {
log.Fatal(err)
}
}