Skip to content

Commit fff001f

Browse files
committed
cmd/loopd: show version on start up, add new --version flag
1 parent 75b6230 commit fff001f

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

cmd/loopd/config.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ type lndConfig struct {
99
type viewParameters struct{}
1010

1111
type config struct {
12-
Insecure bool `long:"insecure" description:"disable tls"`
13-
Network string `long:"network" description:"network to run on" choice:"regtest" choice:"testnet" choice:"mainnet" choice:"simnet"`
14-
SwapServer string `long:"swapserver" description:"swap server address host:port"`
15-
RPCListen string `long:"rpclisten" description:"Address to listen on for gRPC clients"`
16-
RESTListen string `long:"restlisten" description:"Address to listen on for REST clients"`
12+
ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"`
13+
Insecure bool `long:"insecure" description:"disable tls"`
14+
Network string `long:"network" description:"network to run on" choice:"regtest" choice:"testnet" choice:"mainnet" choice:"simnet"`
15+
SwapServer string `long:"swapserver" description:"swap server address host:port"`
16+
RPCListen string `long:"rpclisten" description:"Address to listen on for gRPC clients"`
17+
RESTListen string `long:"restlisten" description:"Address to listen on for REST clients"`
1718

1819
Lnd *lndConfig `group:"lnd" namespace:"lnd"`
1920

cmd/loopd/main.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66
"path/filepath"
7+
"strings"
78
"sync"
89

910
flags "github.com/jessevdk/go-flags"
@@ -72,6 +73,17 @@ func start() error {
7273
return err
7374
}
7475

76+
// Show the version and exit if the version flag was specified.
77+
appName := filepath.Base(os.Args[0])
78+
appName = strings.TrimSuffix(appName, filepath.Ext(appName))
79+
if config.ShowVersion {
80+
fmt.Println(appName, "version", loop.Version())
81+
os.Exit(0)
82+
}
83+
84+
// Print the version before executing either primary directive.
85+
logger.Infof("Version: %v", loop.Version())
86+
7587
// Execute command.
7688
if parser.Active == nil {
7789
return daemon(&config)

0 commit comments

Comments
 (0)