@@ -3,6 +3,7 @@ package stackpack
33import (
44 "bufio"
55 "fmt"
6+ "github.com/stackvista/stackstate-cli/internal/printer"
67 "io"
78 "os"
89 "path/filepath"
@@ -332,33 +333,50 @@ func confirmUpload(cli *di.Deps, zipFile string) bool {
332333// runPackageStep executes the package command logic
333334func runPackageStep (cli * di.Deps , args * PackageArgs ) common.CLIError {
334335 // Reuse the existing package command logic
335- packageCmd := & cobra.Command {}
336- packageFn := RunStackpackPackageCommand (args , true )
337- return packageFn (cli , packageCmd )
336+ return runCmd (cli , func (ctx * di.Deps ) common.CLIError {
337+ packageCmd := & cobra.Command {}
338+ packageFn := RunStackpackPackageCommand (args )
339+ return packageFn (ctx , packageCmd )
340+ })
338341}
339342
340343// runUploadStep executes the upload command logic
341344func runUploadStep (cli * di.Deps , api * stackstate_api.APIClient , serverInfo * stackstate_api.ServerInfo , args * UploadArgs ) common.CLIError {
342- // Reuse the existing upload command logic
343- uploadCmd := & cobra.Command {}
344- uploadFn := RunStackpackUploadCommand (args , true )
345- return uploadFn (uploadCmd , cli , api , serverInfo )
345+ return runCmd (cli , func (ctx * di.Deps ) common.CLIError {
346+ // Reuse the existing upload command logic
347+ uploadCmd := & cobra.Command {}
348+ uploadFn := RunStackpackUploadCommand (args )
349+ return uploadFn (uploadCmd , ctx , api , serverInfo )
350+ })
346351}
347352
348353// runInstallStep executes the install command logic
349354func runInstallStep (cli * di.Deps , api * stackstate_api.APIClient , serverInfo * stackstate_api.ServerInfo , args * InstallArgs ) common.CLIError {
350- // Reuse the existing install command logic
351- installCmd := & cobra.Command {}
352- installFn := RunStackpackInstallCommand (args , true )
353- return installFn (installCmd , cli , api , serverInfo )
355+ return runCmd (cli , func (ctx * di.Deps ) common.CLIError {
356+ // Reuse the existing install command logic
357+ installCmd := & cobra.Command {}
358+ installFn := RunStackpackInstallCommand (args )
359+ return installFn (installCmd , ctx , api , serverInfo )
360+ })
354361}
355362
356363// runUpgradeStep executes the upgrade command logic
357364func runUpgradeStep (cli * di.Deps , api * stackstate_api.APIClient , serverInfo * stackstate_api.ServerInfo , args * UpgradeArgs ) common.CLIError {
358- // Reuse the existing upgrade command logic
359- upgradeCmd := & cobra.Command {}
360- upgradeFn := RunStackpackUpgradeCommand (args , true )
361- return upgradeFn (upgradeCmd , cli , api , serverInfo )
365+ return runCmd (cli , func (ctx * di.Deps ) common.CLIError {
366+ // Reuse the existing upgrade command logic
367+ upgradeCmd := & cobra.Command {}
368+ upgradeFn := RunStackpackUpgradeCommand (args )
369+ return upgradeFn (upgradeCmd , ctx , api , serverInfo )
370+ })
371+ }
372+
373+ func runCmd (cli * di.Deps , f func (ctx * di.Deps ) common.CLIError ) common.CLIError {
374+ oldPr := cli .Printer
375+ pr := printer .NewMockPrinter (nil )
376+ cli .Printer = & pr
377+ err := f (cli )
378+ cli .Printer = oldPr
379+ return err
362380}
363381
364382// getInstalledStackpackVersion checks if a stackpack is installed and returns its version
0 commit comments