Skip to content

Commit

Permalink
Change formatting to 1-liner
Browse files Browse the repository at this point in the history
  • Loading branch information
narasaka committed Nov 16, 2023
1 parent eb3db37 commit d246746
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions go/cli/mcap/cmd/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ func printMetadata(w io.Writer, r io.ReadSeeker, info *mcap.Info) error {
"metadata",
}
rows = append(rows, headers)
// jsonRowSeparator is used to replace the newline characters
// so that the metadata displayed is formatted and wrapped correctly
jsonRowSeparator := "\n" + strings.Repeat("\t", len(headers)-1) + strings.Repeat(" ", len(headers)-1)
for _, idx := range info.MetadataIndexes {
offset := idx.Offset + 1 + 8
if offset > math.MaxInt64 {
Expand All @@ -58,15 +55,11 @@ func printMetadata(w io.Writer, r io.ReadSeeker, info *mcap.Info) error {
if err != nil {
return fmt.Errorf("failed to marshal metadata to JSON: %w", err)
}
prettyJSON, err := utils.PrettyJSON(jsonSerialized)
if err != nil {
return fmt.Errorf("failed to pretty JSON: %w", err)
}
rows = append(rows, []string{
idx.Name,
fmt.Sprintf("%d", idx.Offset),
fmt.Sprintf("%d", idx.Length),
strings.ReplaceAll(prettyJSON, "\n", jsonRowSeparator),
string(jsonSerialized),
})
}
utils.FormatTable(w, rows)
Expand Down

0 comments on commit d246746

Please sign in to comment.