Skip to content

Commit

Permalink
Merge e3f0ae0 into 615d116
Browse files Browse the repository at this point in the history
  • Loading branch information
grundleborg committed Mar 4, 2017
2 parents 615d116 + e3f0ae0 commit 22b3b15
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/platform/import.go
Expand Up @@ -34,6 +34,7 @@ var bulkImportCmd = &cobra.Command{

func init() {
bulkImportCmd.Flags().Bool("apply", false, "Save the import data to the database. Use with caution - this cannot be reverted.")
bulkImportCmd.Flags().Bool("validate", false, "Validate the import data without making any changes to the system.")

importCmd.AddCommand(
bulkImportCmd,
Expand Down Expand Up @@ -81,6 +82,11 @@ func bulkImportCmdF(cmd *cobra.Command, args []string) error {
return errors.New("Apply flag error")
}

validate, err := cmd.Flags().GetBool("validate")
if err != nil {
return errors.New("Validate flag error")
}

if len(args) != 1 {
return errors.New("Incorrect number of arguments.")
}
Expand All @@ -91,7 +97,10 @@ func bulkImportCmdF(cmd *cobra.Command, args []string) error {
}
defer fileReader.Close()

if apply {
if apply && validate {
CommandPrettyPrintln("Use only one of --apply or --validate.")
return nil
} else if apply && !validate {
CommandPrettyPrintln("Running Bulk Import. This may take a long time.")
} else {
CommandPrettyPrintln("Running Bulk Import Data Validation.")
Expand Down

0 comments on commit 22b3b15

Please sign in to comment.