/
main.go
47 lines (36 loc) · 907 Bytes
/
main.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
40
41
42
43
44
45
46
47
package main
import (
"fmt"
"os"
"github.com/0xAX/notificator"
"github.com/atotto/clipboard"
)
func main() {
notify := notificator.New(notificator.Options{
AppName: "Pretty Print",
})
input, err := getInput()
if err != nil {
fmt.Fprintln(os.Stderr, err)
if input.options.notifications {
notify.Push("Pretty Print: Error", fmt.Sprint(err), "", notificator.UR_CRITICAL)
}
os.Exit(1)
}
formatted, err := format(input)
if err != nil {
fmt.Fprintln(os.Stderr, err)
if input.options.notifications {
notify.Push("Pretty Print: Error", fmt.Sprint(err), "", notificator.UR_CRITICAL)
}
os.Exit(1)
}
if input.options.clipboard {
clipboard.WriteAll(string(formatted))
}
fmt.Print(string(formatted))
if input.options.notifications {
notify.Push("Pretty Print: Success", fmt.Sprintf("Data formatted as %v", input.format), "", notificator.UR_NORMAL)
}
os.Exit(0)
}