M CHANGELOG.md => CHANGELOG.md +3 -0
@@ 2,6 2,9 @@
**Note:** Please add newest entries on top. Use ISO date format YYYY-MM-DD and markdown formatting.
+## 2023-11-30
+- feat: Implement initial version of Unix pipe support. Feature development is in progress.
+
## 2023-11-15
- refactor: Make some warning messages' format more uniform.
- refactor: Unified how error meessages are implemented.
M src/nudge.go => src/nudge.go +15 -0
@@ 270,6 270,21 @@ func initFlags(notificationToSend *Notification, runtimeConfiguration *RuntimeCo
if isInputFromPipe(logger) == false && flag.NArg() == 1 {
logger.Debugf("Program is called directly, and we have a single argument, so using it as the message body.")
notificationToSend.messageBody = flag.Arg(0)
+ } else if isInputFromPipe(logger) == true {
+ // If we're operating under pipe mode, Stdin is still available to us.
+ logger.Warnf("Pipe support is under development, and not completed yet. Use at your own risk.")
+ messageSize, err := fmt.Scanln(¬ificationToSend.messageBody)
+
+ if err != nil {
+ if err.Error() == "unexpected newline" {
+ logger.Debugf("%s is encountered, and possibly the message is empty. Continuing.")
+ } else {
+ logger.Panicf("Something went wrong while getting the message from the pipe (Error is %s)", err)
+ }
+ }
+
+ logger.Debugf("Got a message with length of %d.", messageSize)
+ flagStorage.dryrun = true
}
// Print how many arguments we got, as a debug message. flag.Narg() returns the number