[Minor] Rename cli flag folder to email-folder (#343)
rename cli flag mail to email
This commit is contained in:
parent
d00332f328
commit
7f60c00466
@ -16,8 +16,8 @@ import (
|
|||||||
|
|
||||||
// exchange bucket info from flags
|
// exchange bucket info from flags
|
||||||
var (
|
var (
|
||||||
folder string
|
emailFolder string
|
||||||
mail string
|
email string
|
||||||
backupID string
|
backupID string
|
||||||
user string
|
user string
|
||||||
)
|
)
|
||||||
@ -32,8 +32,8 @@ func addExchangeCommands(parent *cobra.Command) *cobra.Command {
|
|||||||
switch parent.Use {
|
switch parent.Use {
|
||||||
case restoreCommand:
|
case restoreCommand:
|
||||||
c, fs = utils.AddCommand(parent, exchangeRestoreCmd)
|
c, fs = utils.AddCommand(parent, exchangeRestoreCmd)
|
||||||
fs.StringVar(&folder, "folder", "", "Name of the mail folder being restored")
|
fs.StringVar(&emailFolder, "email-folder", "", "Name of the email folder being restored")
|
||||||
fs.StringVar(&mail, "mail", "", "ID of the mail message being restored")
|
fs.StringVar(&email, "email", "", "ID of the email being restored")
|
||||||
fs.StringVar(&backupID, "backup", "", "ID of the backup to restore")
|
fs.StringVar(&backupID, "backup", "", "ID of the backup to restore")
|
||||||
cobra.CheckErr(c.MarkFlagRequired("backup"))
|
cobra.CheckErr(c.MarkFlagRequired("backup"))
|
||||||
fs.StringVar(&user, "user", "", "ID of the user whose exchange data will get restored")
|
fs.StringVar(&user, "user", "", "ID of the user whose exchange data will get restored")
|
||||||
@ -59,7 +59,7 @@ func restoreExchangeCmd(cmd *cobra.Command, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := validateRestoreFlags(user, folder, mail, backupID); err != nil {
|
if err := validateRestoreFlags(user, emailFolder, email, backupID); err != nil {
|
||||||
return errors.Wrap(err, "Missing required flags")
|
return errors.Wrap(err, "Missing required flags")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ func restoreExchangeCmd(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
defer utils.CloseRepo(ctx, r)
|
defer utils.CloseRepo(ctx, r)
|
||||||
|
|
||||||
ro, err := r.NewRestore(ctx, backupID, exchangeRestoreSelectors(user, folder, mail))
|
ro, err := r.NewRestore(ctx, backupID, exchangeRestoreSelectors(user, emailFolder, email))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Failed to initialize Exchange restore")
|
return errors.Wrap(err, "Failed to initialize Exchange restore")
|
||||||
}
|
}
|
||||||
@ -127,11 +127,11 @@ func validateRestoreFlags(u, f, m, rpid string) error {
|
|||||||
return errors.New("a restore point ID is requried")
|
return errors.New("a restore point ID is requried")
|
||||||
}
|
}
|
||||||
lu, lf, lm := len(u), len(f), len(m)
|
lu, lf, lm := len(u), len(f), len(m)
|
||||||
if (lu == 0 || u == utils.Wildcard) && (lf+lm > 0) {
|
if (lu == 0 || u == "*") && (lf+lm > 0) {
|
||||||
return errors.New("a specific --user must be provided if --folder or --mail is specified")
|
return errors.New("a specific --user must be provided if --email-folder or --email is specified")
|
||||||
}
|
}
|
||||||
if (lf == 0 || f == utils.Wildcard) && lm > 0 {
|
if (lf == 0 || f == "*") && lm > 0 {
|
||||||
return errors.New("a specific --folder must be provided if a --mail is specified")
|
return errors.New("a specific --email-folder must be provided if a --email is specified")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user