Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ then writes the result as a
document to standard output.

To build it, just run `go build`.

To test it with the included test archive, run `cat test.dump | ./mongodump-parser`.
(Append `| jq` to that command to improve the output’s legibility.)
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ type Report struct {
}

func main() {
colWidth, _, err := term.GetSize(int(os.Stdin.Fd()))
if term.IsTerminal(int(os.Stdin.Fd())) {
fmt.Fprintf(os.Stderr, "NOTE: Standard input is a terminal, which is unusual. Did you maybe mean to `cat` an archive file into this tool?\n")
}

colWidth, _, err := term.GetSize(int(os.Stdout.Fd()))
if err != nil {
colWidth = defaultColumnWidth
}
Expand All @@ -39,6 +43,10 @@ func main() {
Usage: "parse mongodump archive files",
Description: wordwrap.WrapString("This tool reads a mongodump archive file from standard input, parses its header, then outputs the parse to standard output in MongoDB Extended JSON. This lets you see an archive’s contents without actually restoring it.", uint(colWidth-4)),
Action: func(_ context.Context, cmd *cli.Command) error {
if cmd.Args().Len() > 0 {
return fmt.Errorf("unrecognized: %v", cmd.Args().Slice())
}

return run(cmd)
},
}
Expand Down