Skip to content

Commit

Permalink
feat(user): Add -A flag for printing packet data in ASCII (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
mozillazg authored Aug 25, 2024
1 parent feb5b06 commit 403b601
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Options struct {
onlyPrintCount bool
printDataAsHex int
printDataAsHexASCII int
printDataAsASCII bool

timeStampPrecision string
timeStampMicro bool
Expand Down Expand Up @@ -167,5 +168,8 @@ func (o Options) applyToStdoutWriter(w *writer.StdoutWriter) {
case opts.printDataAsHex == 1:
w.DataStyle = pktdump.ContentStyleHex
break
case opts.printDataAsASCII:
w.DataStyle = pktdump.ContentStyleASCII
break
}
}
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ func init() {
"When parsing and printing, in addition to printing the headers of each packet, print the data of each packet in hex")
rootCmd.Flags().CountVarP(&opts.printDataAsHexASCII, "print-data-in-hex-ascii", "X",
"When parsing and printing, in addition to printing the headers of each packet, print the data of each packet in hex and ASCII")
rootCmd.Flags().BoolVarP(&opts.printDataAsASCII, "print-data-in-ascii", "A", false,
"Print each packet (minus its link level header) in ASCII")

silenceKlog()
}
Expand Down

0 comments on commit 403b601

Please sign in to comment.