diff options
author | George Goldberg <george@gberg.me> | 2017-03-06 13:01:22 +0000 |
---|---|---|
committer | enahum <nahumhbl@gmail.com> | 2017-03-06 10:01:22 -0300 |
commit | 6e3e5b8aea1567663baf3ceb86e53ffb9ad90fbe (patch) | |
tree | 30aa2aa193abe785175105bc551f9cd4d99832b8 /cmd/platform/import.go | |
parent | 15f54a1078bf272ef2ebb9bf29d039904fde6edf (diff) | |
download | chat-6e3e5b8aea1567663baf3ceb86e53ffb9ad90fbe.tar.gz chat-6e3e5b8aea1567663baf3ceb86e53ffb9ad90fbe.tar.bz2 chat-6e3e5b8aea1567663baf3ceb86e53ffb9ad90fbe.zip |
PLT-5697: Add --validate flag to bulk import CLI. (#5642)
Diffstat (limited to 'cmd/platform/import.go')
-rw-r--r-- | cmd/platform/import.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/cmd/platform/import.go b/cmd/platform/import.go index 2f995aad2..d0b2de162 100644 --- a/cmd/platform/import.go +++ b/cmd/platform/import.go @@ -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, @@ -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.") } @@ -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.") |