1
0
mirror of https://github.com/google/gops.git synced 2024-11-27 08:31:17 +02:00
gops/main.go

40 lines
988 B
Go
Raw Normal View History

2016-11-04 07:43:04 +02:00
// Copyright 2016 The Go Authors. All rights reserved.
2016-11-04 01:56:19 +02:00
// 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.
2016-11-03 23:01:55 +02:00
package main
import (
"log"
"os"
"strconv"
"github.com/google/gops/internal/cmd"
2016-11-03 23:01:55 +02:00
)
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)
}
}