Skip to content

Commit

Permalink
Add version flag and blurbs
Browse files Browse the repository at this point in the history
  • Loading branch information
thrasher- committed Jan 16, 2018
1 parent 4d4c85f commit 3e30bb7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"flag"
"fmt"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -36,9 +37,16 @@ func main() {

//Handle flags
flag.StringVar(&bot.configFile, "config", config.GetFilePath(""), "config file to load")
version := flag.Bool("version", false, "retrieves current GoCryptoTrader version")
flag.Parse()

if *version {
fmt.Printf(BuildVersion(true))
os.Exit(0)
}

bot.config = &config.Cfg
fmt.Println(BuildVersion(false))
log.Printf("Loading config file %s..\n", bot.configFile)

err := bot.config.LoadConfig(bot.configFile)
Expand Down
40 changes: 40 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package main

import "fmt"

// const vars related to the app version
const (
MajorVersion = "0"
MinorVersion = "1"

PrereleaseBlurb = "This version is pre-release and is not inteded to be used as a production ready trading framework or bot - use at your own risk."
IsRelease = false
Copyright = "Copyright (c) 2018 The GoCryptoTrader Developers."
GitHub = "GitHub: https://github.com/thrasher-/gocryptotrader"
Trello = "Trello: https://trello.com/b/ZAhMhpOy/gocryptotrader"
Slack = "Slack: https://gocryptotrader.herokuapp.com"
Issues = "Issues: https://github.com/thrasher-/gocryptotrader/issues"
)

// BuildVersion returns the version string
func BuildVersion(short bool) string {
versionStr := fmt.Sprintf("GoCryptoTrader v%s.%s",
MajorVersion, MinorVersion)
if !IsRelease {
versionStr += " pre-release.\n"
if !short {
versionStr += PrereleaseBlurb + "\n"
}
} else {
versionStr += " release.\n"
}
if short {
return versionStr
}
versionStr += Copyright + "\n\n"
versionStr += GitHub + "\n"
versionStr += Trello + "\n"
versionStr += Slack + "\n"
versionStr += Issues + "\n"
return versionStr
}

0 comments on commit 3e30bb7

Please sign in to comment.