node: add --only flag to list-nodes

commit-id:4f7d40fc
This commit is contained in:
Leo 2021-12-16 17:12:13 +01:00
parent ce85d8b717
commit 1e4ecef4ce
1 changed files with 15 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import (
"log"
"os"
"sort"
"strings"
"text/tabwriter"
"time"
)
@ -18,10 +19,12 @@ import (
var (
showDetails bool
only []string
)
func init() {
AdminClientListNodes.Flags().BoolVar(&showDetails, "showDetails", false, "Show error counter and contract addresses")
AdminClientListNodes.Flags().StringSliceVar(&only, "only", nil, "Show only networks with the given name")
}
var AdminClientListNodes = &cobra.Command{
@ -104,6 +107,18 @@ func runListNodes(cmd *cobra.Command, args []string) {
networks = append(networks, network{"Ropsten", vaa.ChainIDEthereumRopsten})
}
if len(only) > 0 {
var filtered []network
for _, network := range networks {
for _, name := range only {
if strings.ToLower(name) == strings.ToLower(network.string) {
filtered = append(filtered, network)
}
}
}
networks = filtered
}
for _, k := range networks {
headers = append(headers, k.string)
}