forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 3
/
flags.go
71 lines (61 loc) · 1.69 KB
/
flags.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package e2e
import (
"flag"
"fmt"
"os"
"github.com/MetalBlockchain/metalgo/tests/fixture/tmpnet"
)
type FlagVars struct {
avalancheGoExecPath string
pluginDir string
networkDir string
useExistingNetwork bool
}
func (v *FlagVars) AvalancheGoExecPath() string {
return v.avalancheGoExecPath
}
func (v *FlagVars) PluginDir() string {
return v.pluginDir
}
func (v *FlagVars) NetworkDir() string {
if !v.useExistingNetwork {
return ""
}
if len(v.networkDir) > 0 {
return v.networkDir
}
return os.Getenv(tmpnet.NetworkDirEnvName)
}
func (v *FlagVars) UseExistingNetwork() bool {
return v.useExistingNetwork
}
func RegisterFlags() *FlagVars {
vars := FlagVars{}
flag.StringVar(
&vars.avalancheGoExecPath,
"metalgo-path",
os.Getenv(tmpnet.AvalancheGoPathEnvName),
fmt.Sprintf("metalgo executable path (required if not using an existing network). Also possible to configure via the %s env variable.", tmpnet.AvalancheGoPathEnvName),
)
flag.StringVar(
&vars.pluginDir,
"plugin-dir",
os.ExpandEnv("$HOME/.metalgo/plugins"),
"[optional] the dir containing VM plugins.",
)
flag.StringVar(
&vars.networkDir,
"network-dir",
"",
fmt.Sprintf("[optional] the dir containing the configuration of an existing network to target for testing. Will only be used if --use-existing-network is specified. Also possible to configure via the %s env variable.", tmpnet.NetworkDirEnvName),
)
flag.BoolVar(
&vars.useExistingNetwork,
"use-existing-network",
false,
"[optional] whether to target the existing network identified by --network-dir.",
)
return &vars
}