You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
545 B
31 lines
545 B
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package main
|
|
|
|
import "strconv"
|
|
|
|
// boolFlag is a flag.Value that tracks whether it was ever set.
|
|
type boolFlag struct {
|
|
set bool
|
|
v bool
|
|
}
|
|
|
|
func (b *boolFlag) String() string {
|
|
if b == nil || !b.set {
|
|
return "unset"
|
|
}
|
|
return strconv.FormatBool(b.v)
|
|
}
|
|
|
|
func (b *boolFlag) Set(s string) error {
|
|
v, err := strconv.ParseBool(s)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
b.v = v
|
|
b.set = true
|
|
return nil
|
|
}
|
|
|
|
func (b *boolFlag) IsBoolFlag() bool { return true }
|
|
|