blob: c1423e036284ce8c20067e4e4c08c27ae773b783 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package main
import (
"fmt"
"github.com/mongodb/mongo-tools/common/log"
commonopts "github.com/mongodb/mongo-tools/common/options"
"github.com/mongodb/mongo-tools/common/util"
"github.com/mongodb/mongo-tools/mongodump"
"github.com/mongodb/mongo-tools/mongodump/options"
"os"
)
func main() {
// initialize command-line opts
opts := commonopts.New("mongodump", "<options>")
inputOpts := &options.InputOptions{}
opts.AddOptions(inputOpts)
outputOpts := &options.OutputOptions{}
opts.AddOptions(outputOpts)
_, err := opts.Parse()
if err != nil {
fmt.Printf("error parsing command line options: %v\n\n", err)
fmt.Printf("try 'mongodump --help' for more information\n")
os.Exit(2)
}
// print help, if specified
if opts.PrintHelp() {
return
}
// print version, if specified
if opts.PrintVersion() {
return
}
// init logger
log.SetVerbosity(opts.Verbosity)
dump := mongodump.MongoDump{
ToolOptions: opts,
OutputOptions: outputOpts,
InputOptions: inputOpts,
}
err = dump.Init()
if err != nil {
util.Exitf(1, "%v", err)
}
err = dump.Dump()
if err != nil {
util.Exitf(1, "%v", err)
}
}
|