aboutsummaryrefslogtreecommitdiffstats
path: root/client/go/internal/admin/clusterstate/show_hidden.go
blob: 11cbd5bdca8a182baf6d32ec34ae9748a661fc6c (plain) (blame)
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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// Author: arnej

// utilities to get and manipulate node states in a storage cluster
package clusterstate

import (
	"strconv"

	"github.com/spf13/cobra"
	"github.com/spf13/pflag"
)

// handle CLI flag --show-hidden

type showHiddenFlag struct {
	showHidden bool
	cmd        *cobra.Command
}

func (v *showHiddenFlag) Type() string {
	return ""
}

func (v *showHiddenFlag) String() string {
	return strconv.FormatBool(v.showHidden)
}

func (v *showHiddenFlag) Set(val string) error {
	b, err := strconv.ParseBool(val)
	v.showHidden = b
	v.cmd.Flags().VisitAll(func(f *pflag.Flag) { f.Hidden = false })
	return err
}

func (v *showHiddenFlag) IsBoolFlag() bool { return true }