Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

properly use the version set by goreleaser #14

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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