2
0
mirror of https://github.com/lightninglabs/loop synced 2024-11-17 21:25:56 +00:00

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

This commit is contained in:
Olaoluwa Osuntokun 2019-03-20 17:16:07 -07:00
parent 75b6230e4a
commit fff001fd2e
No known key found for this signature in database
GPG Key ID: CE58F7F8E20FD9A2
2 changed files with 18 additions and 5 deletions

View File

@ -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"`

View File

@ -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)