Add stream user --notifications-only
authorMikael Berthe <mikael@lilotux.net>
Sun, 21 May 2017 12:31:32 +0200
changeset 144 15ecc49bbb25
parent 143 abfa3aa97b51
child 145 0f6b8411ad36
Add stream user --notifications-only
cmd/stream.go
--- a/cmd/stream.go	Sun May 21 12:31:06 2017 +0200
+++ b/cmd/stream.go	Sun May 21 12:31:32 2017 +0200
@@ -17,7 +17,8 @@
 )
 
 var streamOpts struct {
-	command string
+	command           string
+	notificationsOnly bool
 }
 
 // Maximum number of websockets (1 hashtag <=> 1 ws)
@@ -51,6 +52,7 @@
 	RootCmd.AddCommand(streamCmd)
 
 	streamCmd.Flags().StringVar(&streamOpts.command, "command", "", "Execute external command")
+	streamCmd.Flags().BoolVar(&streamOpts.notificationsOnly, "notifications-only", false, "Display only notifications (user stream)")
 }
 
 func streamRunE(cmd *cobra.Command, args []string) error {
@@ -176,6 +178,9 @@
 				}
 				errPrint("Event: [%s]", ev.Event)
 			case "update":
+				if streamOpts.notificationsOnly {
+					continue
+				}
 				s := ev.Data.(madon.Status)
 				if err = p.printObj(&s); err != nil {
 					break LISTEN
@@ -188,6 +193,9 @@
 				}
 				continue
 			case "delete":
+				if streamOpts.notificationsOnly {
+					continue
+				}
 				// TODO PrintObj ?
 				errPrint("Event: [%s] Status %d was deleted", ev.Event, ev.Data.(int64))
 			default: