1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-27 10:53:42 +02:00

Adding getopt and some cli flags.

This commit is contained in:
Henrik Hautakoski 2022-01-17 13:45:55 +01:00
parent 164d0a4153
commit 2b55546e5e
No known key found for this signature in database
GPG key ID: 608414D93E862CCD
3 changed files with 23 additions and 1 deletions

20
main.go
View file

@ -2,11 +2,13 @@
package main
import (
"fmt"
"os"
"os/signal"
"context"
"log"
"time"
"github.com/pborman/getopt/v2"
eos "github.com/eoscanada/eos-go"
shipclient "github.com/eosswedenorg-go/eos-ship-client"
)
@ -79,8 +81,24 @@ func main() {
var err error
showHelp := getopt.BoolLong("help", 'h', "display this help text")
showVersion := getopt.BoolLong("version", 'v', "display this help text")
configFile := getopt.StringLong("config", 'c', "./config.json", "Config file to read", "file")
getopt.Parse()
if *showHelp {
getopt.Usage()
return
}
if *showVersion {
fmt.Println("v0.0.0")
return
}
// Parse config
config, err = LoadConfig("config.json")
config, err = LoadConfig(*configFile)
if err != nil {
log.Println(err)
return