aboutsummaryrefslogtreecommitdiffstats
path: root/notifier/notifier.go
blob: 67798923aa5d1b8e0e418fab83b9a84136ed3c21 (plain)
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
40
41
42
43
44
45
46
47
48
// Copyright 2016 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.

package main

import (
	"fmt"
	"log"
	"runtime"

	"gopkg.in/alecthomas/kingpin.v2"

	pkg "github.com/keybase/go-notifier"
)

var (
	title     = kingpin.Flag("title", "Title").String()
	message   = kingpin.Flag("message", "Message").String()
	imagePath = kingpin.Flag("image-path", "Image path").String()
	bundleID  = kingpin.Flag("bundle-id", "Bundle identifier (for OS X)").String()
	toastPath = kingpin.Flag("toast-path", "Path to toast.exe (for Windows)").String()
)

func main() {
	kingpin.Version("0.1.1")
	kingpin.Parse()

	if runtime.GOOS == "windows" && *toastPath == "" {
		log.Fatal(fmt.Errorf("Need to specify --toast-path for Windows"))
	}

	notifier, err := pkg.NewNotifier()
	if err != nil {
		log.Fatal(err)
	}

	notification := pkg.Notification{
		Title:     *title,
		Message:   *message,
		ImagePath: *imagePath,
		BundleID:  *bundleID,
		ToastPath: *toastPath,
	}

	if err := notifier.DeliverNotification(notification); err != nil {
		log.Fatal(err)
	}
}