Skip to content

Commit

Permalink
plan cli command just outputs json plan
Browse files Browse the repository at this point in the history
  • Loading branch information
coffee-cup committed Jan 30, 2025
1 parent b92fbfa commit c7fe313
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions cli/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"path/filepath"

"github.com/charmbracelet/log"
"github.com/railwayapp/railpack/core"
"github.com/urfave/cli/v3"
)

Expand All @@ -27,30 +26,18 @@ var PlanCommand = &cli.Command{
Aliases: []string{"o"},
Usage: "output file name",
},
&cli.StringFlag{
Name: "format",
Usage: "output format. one of: pretty, json",
Value: "pretty",
},
},
Action: func(ctx context.Context, cmd *cli.Command) error {
buildResult, _, _, err := GenerateBuildResultForCommand(cmd)
if err != nil {
return cli.Exit(err, 1)
}

format := cmd.String("format")

var buildResultString string
if format == "pretty" {
buildResultString = core.FormatBuildResult(buildResult)
} else {
serializedPlan, err := json.MarshalIndent(buildResult.Plan, "", " ")
if err != nil {
return cli.Exit(err, 1)
}
buildResultString = string(serializedPlan)
serializedPlan, err := json.MarshalIndent(buildResult.Plan, "", " ")
if err != nil {
return cli.Exit(err, 1)
}
buildResultString := string(serializedPlan)

output := cmd.String("out")
if output == "" {
Expand Down

0 comments on commit c7fe313

Please sign in to comment.