cmd/loopd: show version on start up, add new --version flag

pull/22/head
Olaoluwa Osuntokun 5 years ago
parent 75b6230e4a
commit fff001fd2e
No known key found for this signature in database
GPG Key ID: CE58F7F8E20FD9A2

@ -9,11 +9,12 @@ type lndConfig struct {
type viewParameters struct{}
type config struct {
Insecure bool `long:"insecure" description:"disable tls"`
Network string `long:"network" description:"network to run on" choice:"regtest" choice:"testnet" choice:"mainnet" choice:"simnet"`
SwapServer string `long:"swapserver" description:"swap server address host:port"`
RPCListen string `long:"rpclisten" description:"Address to listen on for gRPC clients"`
RESTListen string `long:"restlisten" description:"Address to listen on for REST clients"`
ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"`
Insecure bool `long:"insecure" description:"disable tls"`
Network string `long:"network" description:"network to run on" choice:"regtest" choice:"testnet" choice:"mainnet" choice:"simnet"`
SwapServer string `long:"swapserver" description:"swap server address host:port"`
RPCListen string `long:"rpclisten" description:"Address to listen on for gRPC clients"`
RESTListen string `long:"restlisten" description:"Address to listen on for REST clients"`
Lnd *lndConfig `group:"lnd" namespace:"lnd"`

@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"sync"
flags "github.com/jessevdk/go-flags"
@ -72,6 +73,17 @@ func start() error {
return err
}
// Show the version and exit if the version flag was specified.
appName := filepath.Base(os.Args[0])
appName = strings.TrimSuffix(appName, filepath.Ext(appName))
if config.ShowVersion {
fmt.Println(appName, "version", loop.Version())
os.Exit(0)
}
// Print the version before executing either primary directive.
logger.Infof("Version: %v", loop.Version())
// Execute command.
if parser.Active == nil {
return daemon(&config)

Loading…
Cancel
Save