Permalink
Browse files

add ability to ignore certain message types in dump-raw

  • Loading branch information...
justone committed May 15, 2017
1 parent 9c21ec1 commit a3e706c364b123d925783546412d5ab857ab9d86
Showing with 13 additions and 1 deletion.
  1. +13 −1 dump_raw.go
@@ -5,11 +5,13 @@ import (
"encoding/json"
"fmt"
"github.com/Sirupsen/logrus"
"github.com/justone/pmb/api"
)
type DumpRawCommand struct {
Pretty bool `short:"p" long:"pretty" description:"Pretty print message contents."`
Pretty bool `short:"p" long:"pretty" description:"Pretty print message contents."`
Ignore []string `short:"i" long:"ignore" description:"Message types to ignore."`
}
var dumpRawCommand DumpRawCommand
@@ -35,10 +37,20 @@ func init() {
}
func runDumpRaw(conn *pmb.Connection) error {
ignoreTypes := make(map[string]bool)
for _, ign := range dumpRawCommand.Ignore {
ignoreTypes[ign] = true
}
for {
message := <-conn.In
if _, ok := ignoreTypes[message.Contents["type"].(string)]; ok {
logrus.Debugf("ignoring message of type %s", message.Contents["type"].(string))
continue
}
if dumpRawCommand.Pretty {
var out bytes.Buffer
err := json.Indent(&out, []byte(message.Raw), "", " ")

0 comments on commit a3e706c

Please sign in to comment.