Skip to content

Commit

Permalink
Merge pull request #14 from railwayapp/jr/railpack-version
Browse files Browse the repository at this point in the history
properly use the version set by goreleaser
  • Loading branch information
coffee-cup authored Feb 10, 2025
2 parents d8c39f1 + 4df86a2 commit 90ad4e5
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cli/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var BuildCommand = &cli.Command{
return cli.Exit(err, 1)
}

core.PrettyPrintBuildResult(buildResult)
core.PrettyPrintBuildResult(buildResult, core.PrintOptions{Version: Version})

serializedPlan, err := json.MarshalIndent(buildResult.Plan, "", " ")
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions cli/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/urfave/cli/v3"
)

var Version string // This will be set by main

func commonPlanFlags() []cli.Flag {
return []cli.Flag{
&cli.StringSliceFlag{
Expand Down
1 change: 1 addition & 0 deletions cli/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var InfoCommand = &cli.Command{
if format == "pretty" {
buildResultString = core.FormatBuildResult(buildResult, core.PrintOptions{
Metadata: true,
Version: Version,
})
} else {
serializedResult, err := json.MarshalIndent(buildResult, "", " ")
Expand Down
2 changes: 1 addition & 1 deletion cli/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var PrepareCommand = &cli.Command{
}

// Pretty print the result to stdout
core.PrettyPrintBuildResult(buildResult)
core.PrettyPrintBuildResult(buildResult, core.PrintOptions{Version: Version})

// Save plan if requested
if planOut := cmd.String("plan-out"); planOut != "" {
Expand Down
9 changes: 7 additions & 2 deletions cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ import (
urfave "github.com/urfave/cli/v3"
)

var verbose bool
var (
verbose bool
version = "dev" // This will be overwritten by goreleaser
)

func main() {
cli.Version = version

logger := log.Default()
logger.SetTimeFormat("")
urfaveLogWriter := logger.StandardLog(log.StandardLogOptions{
Expand All @@ -29,10 +34,10 @@ func main() {
Name: "railpack",
Usage: "Automatically analyze and generate build plans for applications",
EnableShellCompletion: true,
Version: cli.Version,
Flags: []urfave.Flag{
&urfave.BoolFlag{
Name: "verbose",
Aliases: []string{"v"},
Usage: "Enable verbose logging",
Value: false,
Destination: &verbose,
Expand Down
3 changes: 2 additions & 1 deletion core/prettyPrint.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ var (

type PrintOptions struct {
Metadata bool
Version string
}

func PrettyPrintBuildResult(buildResult *BuildResult, options ...PrintOptions) {
Expand All @@ -69,7 +70,7 @@ func FormatBuildResult(br *BuildResult, options ...PrintOptions) string {
var output strings.Builder

// Header section
header := "Railpack v0.0.1"
header := fmt.Sprintf("Railpack %s", opts.Version)
output.WriteString(headerStyle.Render(header))
output.WriteString("\n")

Expand Down

0 comments on commit 90ad4e5

Please sign in to comment.