From 2103885704ac2c44b97b84a9e3a804550d8e3fbc Mon Sep 17 00:00:00 2001 From: Thomas Osterbind Date: Wed, 7 Feb 2018 12:52:08 -0500 Subject: [PATCH] feat(cmd.export): added optional namespacing flag --- cmd/export.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmd/export.go b/cmd/export.go index e6c3735bb..67de7c37c 100644 --- a/cmd/export.go +++ b/cmd/export.go @@ -59,6 +59,18 @@ To export everything about a dataset, use the --dataset flag.`, ds := res.Dataset path = filepath.Join(path, dsr.Name) + usePeerNameSpace := cmd.Flag("namespaced").Value.String() == "true" + if usePeerNameSpace { + peerName := dsr.Peername + if peerName == "me" { + myProfile, err := r.Profile() + if err != nil { + ExitIfErr(err) + } + peerName = myProfile.Peername + } + path = filepath.Join(peerName, path) + } if cmd.Flag("zip").Value.String() == "true" { dst, err := os.Create(fmt.Sprintf("%s.zip", path)) @@ -179,6 +191,7 @@ func init() { exportCmd.Flags().StringP("output", "o", "", "path to write to, default is current directory") exportCmd.Flags().BoolP("zip", "z", false, "compress export as zip archive") exportCmd.Flags().BoolVarP(&exportCmdAll, "all", "a", false, "export full dataset package") + exportCmd.Flags().BoolVarP(&exportCmdAll, "namespaced", "n", false, "export to a peer name namespaced directory") exportCmd.Flags().BoolVarP(&exportCmdDataset, "dataset", "", false, "export root dataset") exportCmd.Flags().BoolVarP(&exportCmdMeta, "meta", "m", false, "export dataset metadata file") exportCmd.Flags().BoolVarP(&exportCmdStructure, "structure", "s", false, "export dataset structure file")