Skip to content

Commit

Permalink
Allow multiple files to be synced from the CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
marccampbell committed Aug 13, 2019
1 parent ba48a4e commit 8f6064c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/cli/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Apply() *cobra.Command {

cmd.Flags().String("driver", "", "name of the database driver to use")
cmd.Flags().String("uri", "", "connection string uri to use")
cmd.Flags().String("spec-file", "", "filename containing the spec to apply")
cmd.Flags().StringArray("spec-file", []string{}, "filename(s) containing the spec to apply")

cmd.MarkFlagRequired("driver")
cmd.MarkFlagRequired("uri")
Expand Down
13 changes: 12 additions & 1 deletion pkg/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,18 @@ func (d *Database) CreateFixturesSync() error {
}

func (d *Database) ApplySync() error {
specContents, err := ioutil.ReadFile(d.Viper.GetString("spec-file"))
specFiles := d.Viper.GetStringSlice("spec-file")
for _, specFile := range specFiles {
if err := d.applyFileSync(specFile); err != nil {
return err
}
}

return nil
}

func (d *Database) applyFileSync(specFile string) error {
specContents, err := ioutil.ReadFile(specFile)
if err != nil {
return err
}
Expand Down

0 comments on commit 8f6064c

Please sign in to comment.