@@ -29,7 +29,9 @@ import (
2929var _ plugin.Plugin = (* JavaPlugin )(nil )
3030
3131// The JavaPlugin is a cf cli plugin that supports taking heap and thread dumps on demand
32- type JavaPlugin struct {}
32+ type JavaPlugin struct {
33+ verbose bool
34+ }
3335
3436// UUIDGenerator is an interface that encapsulates the generation of UUIDs
3537type UUIDGenerator interface {
@@ -89,26 +91,25 @@ const (
8991// 1 should the plugin exit nonzero.
9092func (c * JavaPlugin ) Run (cliConnection plugin.CliConnection , args []string ) {
9193 // Check if verbose flag is in args for early logging
92- verbose := false
9394 for _ , arg := range args {
9495 if arg == "-v" || arg == "--verbose" {
95- verbose = true
96+ c . verbose = true
9697 break
9798 }
9899 }
99100
100- if verbose {
101+ if c . verbose {
101102 fmt .Printf ("[VERBOSE] Run called with args: %v\n " , args )
102103 }
103104
104105 _ , err := c .DoRun (& commandExecutorImpl {cliConnection : cliConnection }, & uuidGeneratorImpl {}, utils.CfJavaPluginUtilImpl {}, args )
105106 if err != nil {
106- if verbose {
107+ if c . verbose {
107108 fmt .Printf ("[VERBOSE] Error occurred: %v\n " , err )
108109 }
109110 os .Exit (1 )
110111 }
111- if verbose {
112+ if c . verbose {
112113 fmt .Printf ("[VERBOSE] Run completed successfully\n " )
113114 }
114115}
@@ -118,16 +119,7 @@ func (c *JavaPlugin) DoRun(commandExecutor cmd.CommandExecutor, uuidGenerator UU
118119 traceLogger := trace .NewLogger (os .Stdout , true , os .Getenv ("CF_TRACE" ), "" )
119120 ui := terminal .NewUI (os .Stdin , os .Stdout , terminal .NewTeePrinter (os .Stdout ), traceLogger )
120121
121- // Check if verbose flag is in args for early logging
122- verbose := false
123- for _ , arg := range args {
124- if arg == "-v" || arg == "--verbose" {
125- verbose = true
126- break
127- }
128- }
129-
130- if verbose {
122+ if c .verbose {
131123 fmt .Printf ("[VERBOSE] DoRun called with args: %v\n " , args )
132124 }
133125
0 commit comments