You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
817 B
Go
40 lines
817 B
Go
6 years ago
|
package cmd
|
||
|
|
||
|
import (
|
||
|
"../core"
|
||
|
"fmt"
|
||
|
"github.com/spf13/cobra"
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
checkCmd.AddCommand(checkBoxCmd)
|
||
|
rootCmd.AddCommand(checkCmd)
|
||
|
}
|
||
|
|
||
|
var checkCmd = &cobra.Command{
|
||
|
Use: "check",
|
||
|
Short: "One-off check for events on boxes",
|
||
|
Long: "One-off check for events on boxes",
|
||
|
}
|
||
|
|
||
|
var checkBoxCmd = &cobra.Command{
|
||
|
Use: "boxes <boxId> [...<boxIds>]",
|
||
|
Short: "one-off check on one or more box IDs",
|
||
|
Long: "specify box IDs to check them for events",
|
||
|
Args: BoxIdValidator,
|
||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||
|
notifications, err := core.CheckNotifications(args, defaultConf)
|
||
|
if err != nil {
|
||
|
return fmt.Errorf("error checking for notifications:", err)
|
||
|
}
|
||
|
fmt.Println(notifications)
|
||
|
|
||
|
// logNotifications(notifications)
|
||
|
if shouldNotify {
|
||
|
// TODO
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
},
|
||
|
}
|