Skip to content

Commit

Permalink
adding version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
aronchick committed Mar 17, 2022
1 parent 140468d commit 3dcc24c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
11 changes: 10 additions & 1 deletion cmd/bacalhau/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,18 @@ var RootCmd = &cobra.Command{
Long: `Compute over data`,
}

func Execute() {
func Execute(version string) {
RootCmd.Version = version

setVersion()

if err := RootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}

func setVersion() {
template := fmt.Sprintf("Bacalhau Version: %s\n", RootCmd.Version)
RootCmd.SetVersionTemplate(template)
}
6 changes: 3 additions & 3 deletions cmd/bacalhau/submit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ func TestSubmitSyntaxErrors(t *testing.T) {

// https://github.com/koalaman/shellcheck
var (
GOOD_PYTHON = `python3 -c "time.sleep(10); %s"`
MISSING_QUOTE = `python3 -c "time.sleep(10); %s` // note that trailing quote is missing
GOOD_PYTHON = `python3 -c "time.sleep(10); %s"`
MISSING_QUOTE = `python3 -c "time.sleep(10); %s` // note that trailing quote is missing
UNMATCHED_BRACKET = `function f1() {
echo "Hello World"
f1` // Unmatched bracket
f1` // Unmatched bracket
)
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ import (
"github.com/rs/zerolog/log"
)

// Values for version are injected by the build.
var (
VERSION = ""
)

func main() {
logger.Initialize()

start := time.Now()
log.Trace().Msgf("Top of execution - %s", start.UTC())
bacalhau.Execute()
bacalhau.Execute(VERSION)
log.Trace().Msgf("Execution finished - %s", time.Since(start))
}

0 comments on commit 3dcc24c

Please sign in to comment.