Skip to content

Commit

Permalink
fix version flag; fix #24
Browse files Browse the repository at this point in the history
  • Loading branch information
cenkalti committed Sep 11, 2020
1 parent 4a7a888 commit 487ff2d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
24 changes: 19 additions & 5 deletions cmd/dalga/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,32 @@ import (
"github.com/knadh/koanf/providers/file"
)

// These variables are set by goreleaser on build.
var (
config = flag.String("config", "dalga.toml", "config file")
version = flag.Bool("version", false, "print version")
version = "0.0.0"
commit = ""
date = ""
)

var (
configFlag = flag.String("config", "dalga.toml", "config file")
versionFlag = flag.Bool("version", false, "print version")
createTables = flag.Bool("create-tables", false, "create table for storing jobs")
debug = flag.Bool("debug", false, "turn on debug messages")
)

func versionString() string {
if len(commit) > 7 {
commit = commit[:7]
}
return fmt.Sprintf("%s (%s) [%s]", version, commit, date)
}

func main() {
flag.Parse()

if *version {
fmt.Println(dalga.Version)
if *versionFlag {
fmt.Println(versionString())
return
}

Expand Down Expand Up @@ -70,7 +84,7 @@ func main() {
func readConfig() (c dalga.Config, err error) {
c = dalga.DefaultConfig
k := koanf.New(".")
err = k.Load(file.Provider(*config), toml.Parser())
err = k.Load(file.Provider(*configFlag), toml.Parser())
if err != nil {
return
}
Expand Down
2 changes: 0 additions & 2 deletions dalga.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
"github.com/cenkalti/dalga/v3/internal/table"
)

const Version = "2.0.0"

// Dalga is a job scheduler.
type Dalga struct {
config Config
Expand Down

0 comments on commit 487ff2d

Please sign in to comment.