aboutsummaryrefslogtreecommitdiff
path: root/go/weed/export.go
diff options
context:
space:
mode:
authorchrislusf <chris.lu@gmail.com>2015-06-01 19:25:01 -0700
committerchrislusf <chris.lu@gmail.com>2015-06-01 19:25:01 -0700
commit51aac49e82c8683801771729428a2dbffb09e5f6 (patch)
tree0ad4d35917daa2fc246d8c520bece600b94e351c /go/weed/export.go
parente09f45f5edd7786375598d2f6045f69be1b284c6 (diff)
downloadseaweedfs-51aac49e82c8683801771729428a2dbffb09e5f6.tar.xz
seaweedfs-51aac49e82c8683801771729428a2dbffb09e5f6.zip
each command use its own options to avoid parameter collision
fix https://github.com/chrislusf/seaweedfs/issues/152
Diffstat (limited to 'go/weed/export.go')
-rw-r--r--go/weed/export.go30
1 files changed, 20 insertions, 10 deletions
diff --git a/go/weed/export.go b/go/weed/export.go
index 7b2fdb817..f1634dbd1 100644
--- a/go/weed/export.go
+++ b/go/weed/export.go
@@ -15,15 +15,21 @@ import (
"github.com/chrislusf/seaweedfs/go/storage"
)
-func init() {
- cmdExport.Run = runExport // break init cycle
-}
-
const (
defaultFnFormat = `{{.Mime}}/{{.Id}}:{{.Name}}`
timeFormat = "2006-01-02T15:04:05"
)
+var (
+ export ExportOptions
+)
+
+type ExportOptions struct {
+ dir *string
+ collection *string
+ volumeId *int
+}
+
var cmdExport = &Command{
UsageLine: "export -dir=/tmp -volumeId=234 -o=/dir/name.tar -fileNameFormat={{.Name}} -newer='" + timeFormat + "'",
Short: "list or export files from one volume data file",
@@ -34,13 +40,17 @@ var cmdExport = &Command{
`,
}
+func init() {
+ cmdExport.Run = runExport // break init cycle
+ export.dir = cmdExport.Flag.String("dir", ".", "input data directory to store volume data files")
+ export.collection = cmdExport.Flag.String("collection", "", "the volume collection name")
+ export.volumeId = cmdExport.Flag.Int("volumeId", -1, "a volume id. The volume .dat and .idx files should already exist in the dir.")
+ dest = cmdExport.Flag.String("o", "", "output tar file name, must ends with .tar, or just a \"-\" for stdout")
+ format = cmdExport.Flag.String("fileNameFormat", defaultFnFormat, "filename format, default to {{.Mime}}/{{.Id}}:{{.Name}}")
+ newer = cmdExport.Flag.String("newer", "", "export only files newer than this time, default is all files. Must be specified in RFC3339 without timezone")
+}
+
var (
- exportVolumePath = cmdExport.Flag.String("dir", ".", "input data directory to store volume data files")
- exportCollection = cmdExport.Flag.String("collection", "", "the volume collection name")
- exportVolumeId = cmdExport.Flag.Int("volumeId", -1, "a volume id. The volume .dat and .idx files should already exist in the dir.")
- dest = cmdExport.Flag.String("o", "", "output tar file name, must ends with .tar, or just a \"-\" for stdout")
- format = cmdExport.Flag.String("fileNameFormat", defaultFnFormat, "filename format, default to {{.Mime}}/{{.Id}}:{{.Name}}")
- newer = cmdExport.Flag.String("newer", "", "export only files newer than this time, default is all files. Must be specified in RFC3339 without timezone")
tarFh *tar.Writer
tarHeader tar.Header
fnTmpl *template.Template