Skip to content

Commit

Permalink
feat: implemented output build for format json
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwelbm committed Jul 5, 2024
1 parent 7480fcd commit 86d22e2
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions pkg/cmd/build/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,36 @@ import (

msg "github.com/aziontech/azion-cli/messages/build"
"github.com/aziontech/azion-cli/pkg/logger"
"github.com/aziontech/azion-cli/pkg/output"
"go.uber.org/zap"
)

func runCommand(cmd *BuildCmd, command string) error {
logger.FInfo(cmd.Io.Out, msg.BuildStart)
msgs := []string{}
logger.FInfoFlags(cmd.Io.Out, msg.BuildStart, cmd.f.Format, cmd.f.Out)
msgs = append(msgs, msg.BuildStart)

logger.FInfo(cmd.Io.Out, msg.BuildRunningCmd)
logger.FInfo(cmd.Io.Out, fmt.Sprintf("$ %s\n", command))
logger.FInfoFlags(cmd.Io.Out, msg.BuildRunningCmd, cmd.f.Format, cmd.f.Out)
msgs = append(msgs, msg.BuildRunningCmd)
logger.FInfoFlags(cmd.Io.Out, fmt.Sprintf("$ %s\n", command), cmd.f.Format, cmd.f.Out)
msgs = append(msgs, fmt.Sprintf("$ %s\n", command))

err := cmd.CommandRunInteractive(cmd.f, command)
if err != nil {
logger.Debug("Error while running command with simultaneous output", zap.Error(err))
return msg.ErrFailedToRunBuildCommand
}

logger.FInfo(cmd.Io.Out, msg.BuildSuccessful)
return nil
logger.FInfoFlags(cmd.Io.Out, msg.BuildSuccessful, cmd.f.Format, cmd.f.Out)
msgs = append(msgs, msg.BuildSuccessful)

outSlice := output.SliceOutput{
Messages: msgs,
GeneralOutput: output.GeneralOutput{
Out: cmd.f.IOStreams.Out,
Flags: cmd.f.Flags,
},
}

return output.Print(&outSlice)
}

0 comments on commit 86d22e2

Please sign in to comment.