File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,18 @@ func (o *contextOptions) complete(cmd *cobra.Command, args []string) error {
159159
160160func (o * contextOptions ) run () error {
161161
162+ var printFunc func (* contextData )
163+ switch o .output {
164+ case shortOutputConfigValue :
165+ printFunc = o .printShortOutput
166+ case longOutputConfigValue :
167+ printFunc = o .printLongOutput
168+ case jsonOutputConfigValue :
169+ printFunc = o .printJsonOutput
170+ default :
171+ return fmt .Errorf ("Unknown Output Format: %s" , o .output )
172+ }
173+
162174 currentData , dataErrors := o .generateContextData ()
163175 if currentData == nil {
164176 fmt .Fprintf (os .Stderr , "Failed to query cluster info: %+v" , dataErrors )
@@ -172,16 +184,7 @@ func (o *contextOptions) run() error {
172184 }
173185 }
174186
175- switch o .output {
176- case shortOutputConfigValue :
177- o .printShortOutput (currentData )
178- case longOutputConfigValue :
179- o .printLongOutput (currentData )
180- case jsonOutputConfigValue :
181- o .printJsonOutput (currentData )
182- default :
183- return fmt .Errorf ("Unknown Output Format: %s" , o .output )
184- }
187+ printFunc (currentData )
185188
186189 return nil
187190}
You can’t perform that action at this time.
0 commit comments