Skip to content

Commit

Permalink
TOOLS-584 unify usage strings
Browse files Browse the repository at this point in the history
  • Loading branch information
3rf committed Jan 28, 2015
1 parent 7930aa5 commit bd895bc
Show file tree
Hide file tree
Showing 18 changed files with 82 additions and 27 deletions.
2 changes: 1 addition & 1 deletion bsondump/main/bsondump.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func main() {
go signals.Handle()
// initialize command-line opts
opts := options.New("bsondump", "<file>", options.EnabledOptions{})
opts := options.New("bsondump", bsondump.Usage, options.EnabledOptions{})
bsonDumpOpts := &bsondump.BSONDumpOptions{}
opts.AddOptions(bsonDumpOpts)

Expand Down
7 changes: 7 additions & 0 deletions bsondump/options.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package bsondump

var Usage = `<options> <file>
View and debug .bson files.
See http://docs.mongodb.org/manual/reference/program/bsondump/ for more information.`


type BSONDumpOptions struct {
Type string `long:"type" default:"json" default-mask:"-" description:"type of output: debug, json (default 'json')"`
ObjCheck bool `long:"objcheck" description:"validate BSON during processing"`
Expand Down
2 changes: 1 addition & 1 deletion mongodump/main/mongodump.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func main() {
go signals.Handle()
// initialize command-line opts
opts := options.New("mongodump", "<options>", options.EnabledOptions{true, true, true})
opts := options.New("mongodump", mongodump.Usage, options.EnabledOptions{true, true, true})

inputOpts := &mongodump.InputOptions{}
opts.AddOptions(inputOpts)
Expand Down
9 changes: 9 additions & 0 deletions mongodump/options.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package mongodump

var Usage = `<options>
Export the content of a running server into .bson files.
Specify a database with -d and a collection with -c to only dump that database or collection.
See http://docs.mongodb.org/manual/reference/program/mongodump/ for more information.`


type InputOptions struct {
Query string `long:"query" short:"q" description:"query filter, as a JSON string, e.g., '{x:{$gt:1}}'"`
TableScan bool `long:"forceTableScan" description:"force a table scan"`
Expand Down
3 changes: 2 additions & 1 deletion mongoexport/main/mongoexport.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import (
func main() {
go signals.Handle()
// initialize command-line opts
opts := options.New("mongoexport", "<options>", options.EnabledOptions{Auth: true, Connection: true, Namespace: true})
opts := options.New("mongoexport", mongoexport.Usage,
options.EnabledOptions{Auth: true, Connection: true, Namespace: true})

outputOpts := &mongoexport.OutputFormatOptions{}
opts.AddOptions(outputOpts)
Expand Down
8 changes: 7 additions & 1 deletion mongoexport/options.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package mongoexport

var Usage = `<options>
Export data from MongoDB in CSV or JSON format.
See http://docs.mongodb.org/manual/reference/program/mongoexport/ for more information.`

type OutputFormatOptions struct {
//Fields is an option to directly specify comma-separated fields to export to CSV
Fields string `long:"fields" short:"f" description:"comma separated list of field names, e.g. -f name,age"`
Expand All @@ -8,7 +14,7 @@ type OutputFormatOptions struct {
FieldFile string `long:"fieldFile" description:"file with field names - 1 per line"`

//Type selects the type of output to export as (json or csv)
Type string `long:"type" default:"json" default-mask:"-" description:"the output format, either JSON or CSV (defaults to 'json')"`
Type string `long:"type" default:"json" default-mask:"-" description:"the output format, either json or csv (defaults to 'json')"`

//OutputFile specifies an output file path.
OutputFile string `long:"out" short:"o" description:"output file; if not specified, stdout is used"`
Expand Down
16 changes: 1 addition & 15 deletions mongofiles/main/mongofiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,10 @@ import (
"os"
)

const (
Usage = `[options] command [gridfs filename]
command:
one of (list|search|put|get|delete)
list - list all files. 'gridfs filename' is an optional prefix
which listed filenames must begin with.
search - search all files. 'gridfs filename' is a substring
which listed filenames must contain.
put - add a file with filename 'gridfs filename'
get - get a file with filename 'gridfs filename'
delete - delete all files with filename 'gridfs filename'
`
)

func main() {
go signals.Handle()
// initialize command-line opts
opts := options.New("mongofiles", Usage, options.EnabledOptions{Auth: true, Connection: true, Namespace: false})
opts := options.New("mongofiles", mongofiles.Usage, options.EnabledOptions{Auth: true, Connection: true, Namespace: false})

storageOpts := &mongofiles.StorageOptions{}
opts.AddOptions(storageOpts)
Expand Down
13 changes: 13 additions & 0 deletions mongofiles/options.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
package mongofiles

var Usage = `<options> <command> <filename>
Manipulate gridfs files using the command line.
Possible commands include:
list - list all files; 'filename' is an optional prefix which listed filenames must begin with
search - search all files; 'filename' is a substring which listed filenames must contain
put - add a file with filename 'filename'
get - get a file with filename 'filename'
delete - delete all files with filename 'filename'
See http://docs.mongodb.org/manual/reference/program/mongofiles/ for more information.`

type StorageOptions struct {
// Specified database to use. defaults to 'test' if none is specified
DB string `short:"d" default:"test" default-mask:"-" long:"db" description:"database to use (default is 'test')"`
Expand Down
6 changes: 2 additions & 4 deletions mongoimport/main/mongoimport.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ import (
func main() {
go signals.Handle()
// initialize command-line opts
usageStr := " --host myhost --db my_cms --collection docs < mydocfile." +
"json \n\nImport CSV, TSV or JSON data into MongoDB.\n\nWhen importing " +
"JSON documents, each document must be a separate line of the input file."
opts := options.New("mongoimport", usageStr, options.EnabledOptions{Auth: true, Connection: true, Namespace: true})
opts := options.New("mongoimport", mongoimport.Usage,
options.EnabledOptions{Auth: true, Connection: true, Namespace: true})

inputOpts := &mongoimport.InputOptions{}
opts.AddOptions(inputOpts)
Expand Down
6 changes: 6 additions & 0 deletions mongoimport/options.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package mongoimport

var Usage = `<options> <file>
Import CSV, TSV or JSON data into MongoDB. If no file is provided, the tool reads from stdin.
See http://docs.mongodb.org/manual/reference/program/mongoimport/ for more information.`

type InputOptions struct {
// Fields is an option to directly specify comma-separated fields to import to CSV.
Fields *string `long:"fields" short:"f" description:"comma separated list of field names, e.g. -f name,age"`
Expand Down
3 changes: 2 additions & 1 deletion mongooplog/main/mongooplog.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ func main() {
go signals.Handle()

// initialize command line options
opts := options.New("mongooplog", "<options>", options.EnabledOptions{Auth: true, Connection: true, Namespace: false})
opts := options.New("mongooplog", mongooplog.Usage,
options.EnabledOptions{Auth: true, Connection: true, Namespace: false})

// add the mongooplog-specific options
sourceOpts := &mongooplog.SourceOptions{}
Expand Down
6 changes: 6 additions & 0 deletions mongooplog/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import (
"gopkg.in/mgo.v2/bson"
)

var Usage = `--from <remote host> <options>
Poll operations from the replication oplog of one server, and apply them to another.
See http://docs.mongodb.org/manual/reference/program/mongooplog/ for more information.`

type SourceOptions struct {
From string `long:"from" description:"specify the host for mongooplog to retrive operations from"`
OplogNS string `long:"oplogns" description:"specify the namespace in the --from host where the oplog lives (default 'local.oplog.rs') " default:"local.oplog.rs" default-mask:"-"`
Expand Down
3 changes: 2 additions & 1 deletion mongorestore/main/mongorestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import (
func main() {
go signals.Handle()
// initialize command-line opts
opts := options.New("mongorestore", "<options>", options.EnabledOptions{Auth: true, Connection: true, Namespace: true})
opts := options.New("mongorestore", mongorestore.Usage,
options.EnabledOptions{Auth: true, Connection: true, Namespace: true})
inputOpts := &mongorestore.InputOptions{}
opts.AddOptions(inputOpts)
outputOpts := &mongorestore.OutputOptions{}
Expand Down
9 changes: 9 additions & 0 deletions mongorestore/options.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package mongorestore

var Usage = `<options> <directory or file to restore>
Restore backups generated with mongodump to a running server.
Specify a database with -d to restore a single database from the target directory,
or use -d and -c to restore a single collection from a single .bson file.
See http://docs.mongodb.org/manual/reference/program/mongorestore/ for more information.`

type InputOptions struct {
Objcheck bool `long:"objcheck" description:"validate all objects before inserting"`
OplogReplay bool `long:"oplogReplay" description:"replay oplog for point-in-time restore"`
Expand Down
2 changes: 1 addition & 1 deletion mongostat/main/mongostat.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func main() {
// initialize command-line opts
opts := options.New(
"mongostat",
"[options] <polling interval in seconds>",
mongostat.Usage,
options.EnabledOptions{Connection: true, Auth: true, Namespace: false})

// add mongostat-specific options
Expand Down
6 changes: 6 additions & 0 deletions mongostat/options.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package mongostat

var Usage = `<options> <polling interval in seconds>
Monitor basic MongoDB server statistics.
See http://docs.mongodb.org/manual/reference/program/mongostat/ for more information.`

// Output options for mongostat
type StatOptions struct {
NoHeaders bool `long:"noheaders" description:"don't output column names"`
Expand Down
2 changes: 1 addition & 1 deletion mongotop/main/mongotop.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func main() {
go signals.Handle()

// initialize command-line opts
opts := options.New("mongotop", "<options> <sleeptime>",
opts := options.New("mongotop", mongotop.Usage,
options.EnabledOptions{Auth: true, Connection: true, Namespace: false})

// add mongotop-specific options
Expand Down
6 changes: 6 additions & 0 deletions mongotop/options.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package mongotop

var Usage = `<options> <polling interval in seconds>
Monitor basic usage statistics for each collection.
See http://docs.mongodb.org/manual/reference/program/mongotop/ for more information.`

// Output options for mongotop
type Output struct {
Locks bool `long:"locks" description:"report on use of per-database locks"`
Expand Down

0 comments on commit bd895bc

Please sign in to comment.