alrm/main.go

29 lines
427 B
Go
Raw Normal View History

2020-08-11 03:48:40 -08:00
package main
import (
2020-08-15 17:16:52 -08:00
"encoding/json"
2020-08-11 03:48:40 -08:00
"fmt"
"os"
)
2020-08-12 18:16:15 -08:00
func main() {
2020-08-11 03:48:40 -08:00
if len(os.Args) < 2 {
fmt.Fprintf(os.Stderr, "filename required\n")
os.Exit(1)
}
2020-08-15 17:16:52 -08:00
config, err := ReadConfig(os.Args[1])
2020-08-11 03:48:40 -08:00
if err != nil {
2020-08-15 17:16:52 -08:00
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
2020-08-11 03:48:40 -08:00
os.Exit(1)
}
2020-08-15 17:16:52 -08:00
o, err := json.Marshal(config)
if err != nil {
fmt.Fprintf(os.Stderr, "JSON error: %s\n", err.Error())
os.Exit(1)
2020-08-11 03:48:40 -08:00
}
2020-08-15 17:16:52 -08:00
fmt.Println(string(o))
2020-08-11 03:48:40 -08:00
}