-
Notifications
You must be signed in to change notification settings - Fork 6
/
root.go
69 lines (59 loc) · 1.92 KB
/
root.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package cmd
import (
"fmt"
"log"
"os"
"github.com/spf13/cobra"
)
// build flags
var version string
var gitBranch string
var gitHash string
var buildDate string
var env string
const envRelease = "release"
const envDev = "dev"
const rootShort = "Kelp is a free and open-source trading bot for the Stellar universal marketplace."
const rootLong = `Kelp is a free and open-source trading bot for the Stellar universal marketplace (https://stellar.org).
Learn more about Stellar : https://www.stellar.org
Learn more about Kelp : https://github.com/stellar/kelp`
const kelpExamples = tradeExamples + "\n kelp trade --help"
// RootCmd is the main command for this repo
var RootCmd = &cobra.Command{
Use: "kelp",
Short: rootShort,
Long: rootLong,
Example: kelpExamples,
Run: func(ccmd *cobra.Command, args []string) {
intro := `
__ _______ _ ____ ___ __ __ _____ _____ ___ _ _______ _ ____
\ \ / / ____| | / ___/ _ \| \/ | ____| |_ _/ _ \ | |/ / ____| | | _ \
\ \ /\ / /| _| | | | | | | | | |\/| | _| | || | | | | ' /| _| | | | |_) |
\ V V / | |___| |__| |__| |_| | | | | |___ | || |_| | | . \| |___| |___| __/
\_/\_/ |_____|_____\____\___/|_| |_|_____| |_| \___/ |_|\_\_____|_____|_|
` + version + `
`
fmt.Println(intro)
e := ccmd.Help()
if e != nil {
log.Fatal(e)
}
},
}
func init() {
validateBuild()
RootCmd.AddCommand(tradeCmd)
if env == envDev {
RootCmd.AddCommand(serverCmd)
}
RootCmd.AddCommand(strategiesCmd)
RootCmd.AddCommand(exchanagesCmd)
RootCmd.AddCommand(terminateCmd)
RootCmd.AddCommand(versionCmd)
}
func validateBuild() {
if version == "" || buildDate == "" || gitBranch == "" || gitHash == "" {
fmt.Println("version information not included, please build using the build script (scripts/build.sh)")
os.Exit(1)
}
}