mirror of
https://github.com/jimeh/rbheap.git
synced 2026-02-19 12:56:46 +00:00
Initial starting point for a inspect command
This commit is contained in:
39
cmd/inspect.go
Normal file
39
cmd/inspect.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/jimeh/rbheap/inspect"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// inspectCmd represents the inspect command
|
||||
var inspectCmd = &cobra.Command{
|
||||
Use: "inspect [flags] <dump-file>",
|
||||
Short: "Inspect ObjectSpace dumps from Ruby proceees",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if len(args) != 1 {
|
||||
usage_er(cmd, fmt.Sprintf("requires 1 arg, received %d", len(args)))
|
||||
}
|
||||
|
||||
inspector := inspect.New(args[0])
|
||||
inspector.Verbose = inspectOpts.Verbose
|
||||
inspector.Process()
|
||||
|
||||
inspector.PrintCountByFileAndLines()
|
||||
},
|
||||
}
|
||||
|
||||
var inspectOpts = struct {
|
||||
Verbose bool
|
||||
}{}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(inspectCmd)
|
||||
|
||||
inspectCmd.PersistentFlags().BoolVarP(
|
||||
&inspectOpts.Verbose,
|
||||
"verbose", "v", false,
|
||||
"print verbose information",
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user