bsondump

package
v0.0.0-...-35e6b7d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package bsondump converts BSON files into human-readable formats such as JSON.

Index

Constants

This section is empty.

Variables

View Source
var Usage = `` /* 131-byte string literal not displayed */

Functions

This section is empty.

Types

type BSONDump

type BSONDump struct {
	// generic mongo tool options
	ToolOptions *options.ToolOptions

	// BSONDumpOptions defines options used to control how BSON data is displayed
	BSONDumpOptions *BSONDumpOptions

	// File handle for the output data.
	Out io.WriteCloser

	BSONSource *db.BSONSource
}

BSONDump is a container for the user-specified options and internal state used for running bsondump.

func (*BSONDump) Debug

func (bd *BSONDump) Debug() (int, error)

Debug iterates through the BSON file and for each document it finds, recursively descends into objects and arrays and prints a human readable BSON representation containing the type and size of each field. It returns the number of documents processed and a non-nil error if one is encountered before the end of the file is reached.

func (*BSONDump) JSON

func (bd *BSONDump) JSON() (int, error)

JSON iterates through the BSON file and for each document it finds, recursively descends into objects and arrays and prints the human readable JSON representation. It returns the number of documents processed and a non-nil error if one is encountered before the end of the file is reached.

type BSONDumpOptions

type BSONDumpOptions struct {
	// Format to display the BSON data file
	Type string `long:"type" value-name:"<type>" default:"json" default-mask:"-" description:"type of output: debug, json (default 'json')"`

	// Validate each BSON document before displaying
	ObjCheck bool `long:"objcheck" description:"validate BSON during processing"`

	// Display JSON data with indents
	Pretty bool `long:"pretty" description:"output JSON formatted to be human-readable"`

	// Path to input BSON file
	BSONFileName string `long:"bsonFile" description:"path to BSON file to dump to JSON; default is stdin"`

	// Path to output file
	OutFileName string `long:"outFile" description:"path to output file to dump BSON to; default is stdout"`
}

func (*BSONDumpOptions) GetBSONReader

func (bdo *BSONDumpOptions) GetBSONReader() (io.ReadCloser, error)

GetBSONReader opens and returns an io.ReadCloser for the BSONFileName in BSONDumpOptions or nil if none is set. The caller is responsible for closing it.

func (*BSONDumpOptions) GetWriter

func (bdo *BSONDumpOptions) GetWriter() (io.WriteCloser, error)

GetWriter opens and returns an io.WriteCloser for the OutFileName in BSONDumpOptions or nil if none is set. The caller is responsible for closing it.

func (*BSONDumpOptions) Name

func (_ *BSONDumpOptions) Name() string

func (*BSONDumpOptions) PostParse

func (_ *BSONDumpOptions) PostParse() error

func (*BSONDumpOptions) Validate

func (_ *BSONDumpOptions) Validate() error

type ReadNopCloser

type ReadNopCloser struct {
	io.Reader
}

func (ReadNopCloser) Close

func (ReadNopCloser) Close() error

type WriteNopCloser

type WriteNopCloser struct {
	io.Writer
}

func (WriteNopCloser) Close

func (WriteNopCloser) Close() error

Directories

Path Synopsis
Main package for the bsondump tool.
Main package for the bsondump tool.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL