Uh oh!
There was an error while loading. Please reload this page.
feat: Automatically split STDIN on null characters on push - #70
feat: Automatically split STDIN on null characters on push#70eternal-flame-AD wants to merge 3 commits into
Conversation
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
| read := bufio.NewReader(r) | ||
| for { | ||
| s, err := read.ReadString('\x00') | ||
| if err != nil { |
There was a problem hiding this comment.
This could be simplified, if we always trim the suffix:
s, err:=read.ReadString('\x00')
s=strings.TrimSuffix(s, "\x00")
iflen(s) >0 {
output<-s
}
iferrors.Is(err, io.EOF) {
return
}
iferr!=nil {
utils.Exit1With("read error", err)
}| cli.StringFlag{Name: "contentType", Usage: "The content type of the message. See https://gotify.net/docs/msgextras#client-display"}, | ||
| cli.StringFlag{Name: "clickUrl", Usage: "An URL to open upon clicking the notification. See https://gotify.net/docs/msgextras#client-notification"}, | ||
| cli.BoolFlag{Name: "disable-unescape-backslash", Usage: "Disable evaluating \\n and \\t (if set, \\n and \\t will be seen as a string)"}, | ||
| cli.BoolFlag{Name: "no-split", Usage: "Do not split the message on null character when reading from stdin"}, |
There was a problem hiding this comment.
can we invert this, so we don't changing existing behavior (reading stdin completely and pushing one message).
Uh oh!
There was an error while loading. Please reload this page.
| @@ -71,7 +71,7 @@ func inputConfigLocation() string { | |||
| for { | |||
There was a problem hiding this comment.
How would I use this feature to simplify the journalctl call in #69?
I'm also not 100% sure about the actual use-case of feature, is there something not possible with the current cli feature set and xargs? I don't find the argument that we don't have to use xargs very strong for implementing this inside gotify/cli.
I think if someone doesn't have access to xargs then they probably don't use gotify/cli and instead use some "raw" http call.
There was a problem hiding this comment.
How would I use this feature to simplify the journalctl call in #69?
journalctl -f -u sshd | awk 'NR % 5 == 0 { print "\0"} { print }'| gotify pushis there something not possible with the current cli feature set and xargs
makes sense, maybe I will just cherry pick the formatting bugs to a different PR and do that
This fixes#69.
Added a feature to split on null characters when reading from stdin. This way users can have one long-running
gotify pushand simply piping things to it.