Skip to content

Commit

Permalink
feat(cmd.export): added optional namespacing flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Osterbind committed Feb 7, 2018
1 parent 1533293 commit 2103885
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 2103885

Please sign in to comment.