Skip to content

Commit

Permalink
Merge pull request #199 from ethereum-optimism/10-15-feat_cli_include…
Browse files Browse the repository at this point in the history
…_ldflag_version_in_--version_command

feat(cli): include ldflag version in --version command
  • Loading branch information
jakim929 authored Oct 15, 2024
2 parents 6eae8cf + 8fe22f2 commit edf48a6
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ import (
oplog "github.com/ethereum-optimism/optimism/op-service/log"

"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"

"github.com/joho/godotenv"
"github.com/urfave/cli/v2"
)

var (
GitCommit = ""
GitDate = ""
version = "dev"
commit = "none"
date = "unknown"
)

var (
envVarPrefix = "SUPERSIM"
)

Expand All @@ -45,7 +47,7 @@ func main() {
logFlags := oplog.CLIFlags(envVarPrefix)

app := cli.NewApp()
app.Version = params.VersionWithCommit(GitCommit, GitDate)
app.Version = formatVersion()
app.Name = "supersim"
app.Usage = "Superchain Multi-L2 Simulator"
app.Description = "Local multichain optimism development environment"
Expand Down Expand Up @@ -136,3 +138,14 @@ func isTimestampGreaterOrEqual(timestamp, minTimestamp string) (bool, error) {

return !parsedTimestamp.Before(parsedMinTimestamp), nil
}

func formatVersion() string {
result := version
if commit != "none" {
result += fmt.Sprintf(" (%s)", commit)
}
if date != "unknown" {
result += fmt.Sprintf(" built at %s", date)
}
return result
}

0 comments on commit edf48a6

Please sign in to comment.