forked from ForceCLI/force
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotify.go
39 lines (33 loc) · 805 Bytes
/
notify.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
package command
import (
"fmt"
"strconv"
"github.com/ForceCLI/force/desktop"
"github.com/spf13/cobra"
)
func init() {
RootCmd.AddCommand(notifyCmd)
}
var notifyCmd = &cobra.Command{
Use: "notify (true | false)",
Short: "Should notifications be used",
Long: `
Determines if notifications should be used
`,
Args: cobra.MaximumNArgs(1),
DisableFlagsInUseLine: true,
Run: func(cmd *cobra.Command, args []string) {
var err error
shouldNotify := true
if len(args) == 0 {
shouldNotify = desktop.GetShouldNotify()
fmt.Println("Show notifications: " + strconv.FormatBool(shouldNotify))
return
}
shouldNotify, err = strconv.ParseBool(args[0])
if err != nil {
fmt.Println("Expecting a boolean parameter.")
}
desktop.SetShouldNotify(shouldNotify)
},
}