1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-16 04:24:56 +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

1
go.mod
View file

@ -6,4 +6,5 @@ require (
github.com/eoscanada/eos-go v0.10.1-0.20220112183548-39fba816311f
github.com/eosswedenorg-go/eos-ship-client v0.0.0-20220113161228-7007edec3bb4
github.com/go-redis/redis/v8 v8.11.4
github.com/pborman/getopt/v2 v2.1.0
)

3
go.sum
View file

@ -91,6 +91,9 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.16.0 h1:6gjqkI8iiRHMvdccRJM8rVKjCWk6ZIm6FTm3ddIe4/c=
github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/pborman/getopt v1.1.0 h1:eJ3aFZroQqq0bWmraivjQNt6Dmm5M0h2JcDW38/Azb0=
github.com/pborman/getopt/v2 v2.1.0 h1:eNfR+r+dWLdWmV8g5OlpyrTYHkhVNxHBdN2cCrJmOEA=
github.com/pborman/getopt/v2 v2.1.0/go.mod h1:4NtW75ny4eBw9fO1bhtNdYTlZKYX5/tBLtsOpwKIKd0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

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