aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-10-14 18:07:17 +0200
committern-peugnet <n.peugnet@free.fr>2021-10-15 16:11:43 +0200
commit89fb0a85f78a415477e450b0091d8c2b994b687d (patch)
treeee8283bd91998b65f1a5056f254467a616964653 /main.go
parent347c626f4103f7afd494031cdf9f9fa7868f8e59 (diff)
downloaddna-backup-89fb0a85f78a415477e450b0091d8c2b994b687d.tar.gz
dna-backup-89fb0a85f78a415477e450b0091d8c2b994b687d.zip
start dir exporter
Diffstat (limited to 'main.go')
-rw-r--r--main.go42
1 files changed, 34 insertions, 8 deletions
diff --git a/main.go b/main.go
index ada0252..ae180b9 100644
--- a/main.go
+++ b/main.go
@@ -42,19 +42,25 @@ var (
logLevel int
chunkSize int
format string
+ trackSize int
)
-var commit = command{flag.NewFlagSet("commit", flag.ExitOnError), commitMain,
+var Commit = command{flag.NewFlagSet("commit", flag.ExitOnError), commitMain,
"[<options>] [--] <source> <dest>",
"Create a new version of folder <source> into repo <dest>",
}
-var restore = command{flag.NewFlagSet("restore", flag.ExitOnError), restoreMain,
+var Restore = command{flag.NewFlagSet("restore", flag.ExitOnError), restoreMain,
"[<options>] [--] <source> <dest>",
"Restore the last version from repo <source> into folder <dest>",
}
+var Export = command{flag.NewFlagSet("export", flag.ExitOnError), exportMain,
+ "[<options>] [--] <source> <dest>",
+ "Export versions from repo <source> into folder <dest>",
+}
var subcommands = map[string]command{
- commit.Flag.Name(): commit,
- restore.Flag.Name(): restore,
+ Commit.Flag.Name(): Commit,
+ Restore.Flag.Name(): Restore,
+ Export.Flag.Name(): Export,
}
func init() {
@@ -71,6 +77,8 @@ func init() {
s.Flag.IntVar(&logLevel, "v", 3, "log verbosity level (0-4)")
s.Flag.IntVar(&chunkSize, "c", 8<<10, "chunk size")
}
+ Export.Flag.StringVar(&format, "format", "dir", "format of the export (dir, csv)")
+ Export.Flag.IntVar(&trackSize, "track", 1020, "size of a DNA track")
}
func main() {
@@ -104,8 +112,8 @@ func commitMain(args []string) error {
}
source := args[0]
dest := args[1]
- repo := repo.NewRepo(dest, chunkSize)
- repo.Commit(source)
+ r := repo.NewRepo(dest, chunkSize)
+ r.Commit(source)
return nil
}
@@ -115,7 +123,25 @@ func restoreMain(args []string) error {
}
source := args[0]
dest := args[1]
- repo := repo.NewRepo(source, chunkSize)
- repo.Restore(dest)
+ r := repo.NewRepo(source, chunkSize)
+ r.Restore(dest)
+ return nil
+}
+
+func exportMain(args []string) error {
+ if len(args) != 2 {
+ return fmt.Errorf("wrong number args")
+ }
+ source := args[0]
+ dest := args[1]
+ r := repo.NewRepo(source, chunkSize)
+ switch format {
+ case "dir":
+ r.ExportDir(dest, trackSize)
+ case "csv":
+ fmt.Println("csv")
+ default:
+ logger.Errorf("unknown format %s", format)
+ }
return nil
}