zaphyra's git: airpodsctl

Control and monitor your AirPods

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 
package types

import (
	"fmt"
)

type Bool bool

func (boolean *Bool) Set(value string) (err error) {
	*boolean, err = ParseBool(value)
	return
}

func (value Bool) String() string {
	if value {
		return "Yes"
	}
	return "No"
}

func (value Bool) FormatFeatureString() string {
	if value {
		return "Enabled"
	}
	return "Disabled"
}

func ParseBool(str string) (Bool, error) {
	switch str {
	case "disable", "off":
		return false, nil
	case "enable", "on":
		return true, nil
	}

	return false, fmt.Errorf("Faild to parse Boolean: %s\n", str)
}