@@ -15,6 +15,20 @@ import (
1515 "google.golang.org/protobuf/proto"
1616)
1717
18+ const (
19+ // Environment variables names that can be used to set the global flags.
20+ envVarRPCServer = "TAPCLI_RPCSERVER"
21+ envVarTapDir = "TAPCLI_TAPDIR"
22+ ewnvVarSocksProxy = "TAPCLI_SOCKSPROXY"
23+ envVarTLSCert = "TAPCLI_TLSCERTPATH"
24+ envVarNetwork = "TAPCLI_NETWORK"
25+ envVarMacaroonPath = "TAPCLI_MACAROONPATH"
26+ envVarMacaroonTimeout = "TAPCLI_MACAROONTIMEOUT"
27+ envVarMacaroonIP = "TAPCLI_MACAROONIP"
28+ envVarProfile = "TAPCLI_PROFILE"
29+ envVarMacFromJar = "TAPCLI_MACFROMJAR"
30+ )
31+
1832// NewApp creates a new tapcli app with all the available commands.
1933func NewApp (actionOpts ... ActionOption ) cli.App {
2034 app := cli .NewApp ()
@@ -23,15 +37,17 @@ func NewApp(actionOpts ...ActionOption) cli.App {
2337 app .Usage = "control plane for your Taproot Assets Daemon (tapd)"
2438 app .Flags = []cli.Flag {
2539 cli.StringFlag {
26- Name : "rpcserver" ,
27- Value : defaultRPCHostPort ,
28- Usage : "The host:port of tap daemon." ,
40+ Name : "rpcserver" ,
41+ Value : defaultRPCHostPort ,
42+ Usage : "The host:port of tap daemon." ,
43+ EnvVar : envVarRPCServer ,
2944 },
3045 cli.StringFlag {
3146 Name : "tapddir" ,
3247 Value : defaultTapdDir ,
3348 Usage : "The path to tap's base directory." ,
3449 TakesFile : true ,
50+ EnvVar : envVarTapDir ,
3551 },
3652 cli.StringFlag {
3753 Name : "socksproxy" ,
@@ -44,12 +60,14 @@ func NewApp(actionOpts ...ActionOption) cli.App {
4460 Value : defaultTLSCertPath ,
4561 Usage : "The path to tapd's TLS certificate." ,
4662 TakesFile : true ,
63+ EnvVar : envVarTLSCert ,
4764 },
4865 cli.StringFlag {
4966 Name : "network, n" ,
5067 Usage : "The network tapd is running on, e.g. " +
5168 "mainnet, testnet, etc." ,
52- Value : "testnet" ,
69+ Value : "testnet" ,
70+ EnvVar : envVarNetwork ,
5371 },
5472 cli.BoolFlag {
5573 Name : "no-macaroons" ,
@@ -59,15 +77,20 @@ func NewApp(actionOpts ...ActionOption) cli.App {
5977 Name : "macaroonpath" ,
6078 Usage : "The path to macaroon file." ,
6179 TakesFile : true ,
80+ EnvVar : envVarMacaroonPath ,
6281 },
6382 cli.Int64Flag {
6483 Name : "macaroontimeout" ,
6584 Value : 60 ,
66- Usage : "Anti-replay macaroon validity time in seconds." ,
85+ Usage : "Anti-replay macaroon validity time in " +
86+ "seconds." ,
87+ EnvVar : envVarMacaroonTimeout ,
6788 },
6889 cli.StringFlag {
69- Name : "macaroonip" ,
70- Usage : "If set, lock macaroon to specific IP address." ,
90+ Name : "macaroonip" ,
91+ Usage : "If set, lock macaroon to specific IP " +
92+ "address." ,
93+ EnvVar : envVarMacaroonIP ,
7194 },
7295 cli.StringFlag {
7396 Name : "profile, p" ,
@@ -77,12 +100,14 @@ func NewApp(actionOpts ...ActionOption) cli.App {
77100 "a default profile is set, this flag can be " +
78101 "set to an empty string to disable reading " +
79102 "values from the profiles file." ,
103+ EnvVar : envVarProfile ,
80104 },
81105 cli.StringFlag {
82106 Name : "macfromjar" ,
83107 Usage : "Use this macaroon from the profile's " +
84108 "macaroon jar instead of the default one. " +
85109 "Can only be used if profiles are defined." ,
110+ EnvVar : envVarMacFromJar ,
86111 },
87112 }
88113
0 commit comments