Skip to content

Commit

Permalink
fix: cleanup output of export & dataset commands
Browse files Browse the repository at this point in the history
  • Loading branch information
b5 committed Jan 31, 2018
1 parent 3bce325 commit 4cf18a0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
4 changes: 2 additions & 2 deletions cmd/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ To export everything about a dataset, use the --dataset flag.`,

err = dst.Close()
ExitIfErr(err)
printSuccess("exported dataset data to: %s", dataPath)
printSuccess("exported data to: %s", dataPath)
}

if exportCmdDataset {
Expand All @@ -164,7 +164,7 @@ To export everything about a dataset, use the --dataset flag.`,
err = ioutil.WriteFile(dsPath, dsbytes, os.ModePerm)
ExitIfErr(err)

printSuccess("exported dataset dataset to: %s", dsPath)
printSuccess("exported dataset.json to: %s", dsPath)
}

// err = dsutil.WriteDir(r.Store(), ds, path)
Expand Down
2 changes: 1 addition & 1 deletion cmd/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ overwrite this info.`,
// this is usually a terrible idea
ErrExit(fmt.Errorf("repo already initialized"))
}
fmt.Println("setting up qri repo at: %s", QriRepoPath)
fmt.Printf("setting up qri repo at: %s\n", QriRepoPath)

envVars := map[string]*string{
"QRI_SETUP_CONFIG_DATA": &setupConfigData,
Expand Down
19 changes: 5 additions & 14 deletions core/datasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,6 @@ func (r *DatasetRequests) Init(p *InitParams, res *repo.DatasetRef) error {
if err != nil {
return fmt.Errorf("error reading file: %s", err.Error())
}
// Ensure that dataset is well-formed
// format, err := detect.ExtensionDataFormat(filename)
// if err != nil {
// return fmt.Errorf("error detecting format extension: %s", err.Error())
// }
// if err = validate.DataFormat(format, bytes.NewReader(data)); err != nil {
// return fmt.Errorf("invalid data format: %s", err.Error())
// }

// TODO - finish
// if p.Structure != nil {
// stData, err := ioutil.ReadAll(p.Structure)
// }

st, err := detect.FromReader(filename, bytes.NewReader(data))
if err != nil {
Expand Down Expand Up @@ -292,14 +279,18 @@ func (r *DatasetRequests) Init(p *InitParams, res *repo.DatasetRef) error {
ds.Meta.AccrualPeriodicity = "R/P1W"
}
if p.Metadata != nil {
if err := json.NewDecoder(p.Metadata).Decode(ds); err != nil {
if ds.Meta == nil {
ds.Meta = &dataset.Meta{}
}
if err := json.NewDecoder(p.Metadata).Decode(ds.Meta); err != nil {
return fmt.Errorf("error parsing metadata json: %s", err.Error())
}
}

dataf := memfs.NewMemfileBytes("data."+st.Format.String(), data)
dskey, err := r.repo.CreateDataset(ds, dataf, true)
if err != nil {
fmt.Printf("error creating dataset: %s\n", err.Error())
return err
}

Expand Down

0 comments on commit 4cf18a0

Please sign in to comment.