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:
parent
164d0a4153
commit
2b55546e5e
3 changed files with 23 additions and 1 deletions
20
main.go
20
main.go
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue