Skip to content

Commit bad957b

Browse files
authored
Merge pull request lightninglabs#1007 from gcaracuel/cli_env_global_flags
litcli: Global flags to accept ENV vars overrides.
2 parents deaddc1 + b2f2ea0 commit bad957b

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

cmd/litcli/main.go

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ const (
2727
// defaultMacaroonTimeout is the default macaroon timeout in seconds
2828
// that we set when sending it over the line.
2929
defaultMacaroonTimeout int64 = 60
30+
31+
// Environment variables names that can be used to set the global flags.
32+
envVarRPCServer = "LITCLI_RPCSERVER"
33+
envVarNetwork = "LITCLI_NETWORK"
34+
envVarBaseDir = "LITCLI_BASEDIR"
35+
envVarTLSCert = "LITCLI_TLSCERTPATH"
36+
envVarMacaroonPath = "LITCLI_MACAROONPATH"
37+
envVarLNDDir = "LITCLI_LNDDIR"
38+
envVarMacaroonTimeout = "LITCLI_MACAROONTIMEOUT"
3039
)
3140

3241
var (
@@ -35,25 +44,29 @@ var (
3544
maxMsgRecvSize = grpc.MaxCallRecvMsgSize(1 * 1024 * 1024 * 200)
3645

3746
baseDirFlag = cli.StringFlag{
38-
Name: "basedir",
39-
Value: terminal.DefaultLitDir,
40-
Usage: "Path to LiT's base directory",
47+
Name: "basedir",
48+
Value: terminal.DefaultLitDir,
49+
Usage: "Path to LiT's base directory",
50+
EnvVar: envVarBaseDir,
4151
}
4252
networkFlag = cli.StringFlag{
4353
Name: "network, n",
4454
Usage: "The network litd is running on e.g. mainnet, " +
4555
"testnet, etc.",
46-
Value: terminal.DefaultNetwork,
56+
Value: terminal.DefaultNetwork,
57+
EnvVar: envVarNetwork,
4758
}
4859
tlsCertFlag = cli.StringFlag{
49-
Name: "tlscertpath",
50-
Usage: "Path to lit's TLS certificate",
51-
Value: terminal.DefaultTLSCertPath,
60+
Name: "tlscertpath",
61+
Usage: "Path to lit's TLS certificate",
62+
Value: terminal.DefaultTLSCertPath,
63+
EnvVar: envVarTLSCert,
5264
}
5365
macaroonPathFlag = cli.StringFlag{
54-
Name: "macaroonpath",
55-
Usage: "Path to lit's macaroon file",
56-
Value: terminal.DefaultMacaroonPath,
66+
Name: "macaroonpath",
67+
Usage: "Path to lit's macaroon file",
68+
Value: terminal.DefaultMacaroonPath,
69+
EnvVar: envVarMacaroonPath,
5770
}
5871
)
5972

@@ -65,9 +78,10 @@ func main() {
6578
app.Usage = "control plane for your Lightning Terminal (lit) daemon"
6679
app.Flags = []cli.Flag{
6780
cli.StringFlag{
68-
Name: "rpcserver",
69-
Value: "localhost:8443",
70-
Usage: "LiT daemon address host:port",
81+
Name: "rpcserver",
82+
Value: "localhost:8443",
83+
Usage: "LiT daemon address host:port",
84+
EnvVar: envVarRPCServer,
7185
},
7286
networkFlag,
7387
baseDirFlag,
@@ -82,13 +96,15 @@ func main() {
8296
Usage: "Path to lnd's base directory",
8397
Hidden: true,
8498
Value: commands.DefaultLndDir,
99+
EnvVar: envVarLNDDir,
85100
},
86101
cli.Int64Flag{
87102
Name: "macaroontimeout",
88103
Value: 60,
89104
Hidden: true,
90105
Usage: "Anti-replay macaroon validity time in " +
91106
"seconds.",
107+
EnvVar: envVarMacaroonTimeout,
92108
},
93109
}
94110
app.Commands = append(app.Commands, sessionCommands...)

docs/release-notes/release-notes-0.14.2.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@
1818

1919
### Functional Changes/Additions
2020

21+
* [`litcli`: global flags to allow overrides via environment
22+
variables](https://github.com/lightninglabs/lightning-terminal/pull/1007)
23+
`litcli --help` for more details.
24+
2125
### Technical and Architectural Updates
2226

2327
* Correctly [move a session to the Expired
2428
state](https://github.com/lightninglabs/lightning-terminal/pull/985) instead
2529
of the Revoked state if it is in fact being revoked due to the session expiry
2630
being reached.
2731

28-
2932
## RPC Updates
3033

3134
## Integrated Binary Updates

0 commit comments

Comments
 (0)