commit fbbacff5b7e4a607059e285fb956a39ad57c22ef from: Oliver Lowe date: Tue Jun 15 07:04:02 2021 UTC cmd/pover: accept priority and title command line flags commit - f0f6a77c9214f2d9075e7019327b1cd61afad2e1 commit + fbbacff5b7e4a607059e285fb956a39ad57c22ef blob - 1b4a447771810022d7edab07c1354ae8b73534a9 blob + e04fc51a4fe22c033eecece5cb37c8ba200b238a --- cmd/pover/pover.1 +++ cmd/pover/pover.1 @@ -9,6 +9,7 @@ .Op Fl d .Op Fl f Ar file .Op Fl t Ar title +.Op Fl p Ar priority .Sh DESCRIPTION .Nm sends a notification to Pushover using text read from standard input as the message body. @@ -24,6 +25,10 @@ Sets configuration to be read from Sets the message title to .Ar title . By default there is no title. +.It Fl p Ar priority +Sets the message priority to +.Ar priority . +Valid values are from -2 to 1. The default is 0. .El .Pp Credentials must be present in a configuration file. blob - 9b551d6b99f5fc34d12132c642580b4f9340276a blob + e828c4e90d463568458a235f91648d4f52f85447 --- cmd/pover/pover.go +++ cmd/pover/pover.go @@ -10,14 +10,18 @@ import ( "git.sr.ht/~otl/pushover" ) -const usage string = "usage: pover [-d] [-f file]" +const usage string = "usage: pover [-d] [-f file] [-t title] [-p priority]" var debug *bool var configflag *string +var priorityflag *int +var titleflag *string func init() { debug = flag.Bool("d", false, "debug") configflag = flag.String("f", "", "path to configuration file") + priorityflag = flag.Int("p", 0, "priority") + titleflag = flag.String("t", "", "message title") flag.Parse() } @@ -56,6 +60,12 @@ func main() { Token: config.token, Message: string(b), } + if *titleflag != "" { + msg.Title = *titleflag + } + if *priorityflag != 0 { + msg.Priority = *priorityflag + } if err := pushover.Push(msg); err != nil { fmt.Fprintf(os.Stderr, "push message: %v\n", err) os.Exit(1)