From 1b5ced9b556c255039cfe8140a7c4249067dd0ff Mon Sep 17 00:00:00 2001 From: lzy <674194901@qq.com> Date: Tue, 17 Dec 2024 10:51:05 +0800 Subject: [PATCH] fix: mark incremental flag in backup policy as required --- internal/cli/backup/create.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/cli/backup/create.go b/internal/cli/backup/create.go index 7673d2a2..ba132d17 100644 --- a/internal/cli/backup/create.go +++ b/internal/cli/backup/create.go @@ -193,10 +193,13 @@ func (o *CreateOptions) Validate() error { if o.FullCrontab == "" { return errors.New("Full backup schedule is required, at least one of the full schedule must be specified") } + if o.IncrementalCrontab == "" { + return errors.New("Incremental backup schedule is required, at least one of the incremental schedule must be specified") + } if !checkCrontabSyntax(o.FullCrontab) { return errors.New("Invalid full backup schedule") } - if o.IncrementalCrontab != "" && !checkCrontabSyntax(o.IncrementalCrontab) { + if !checkCrontabSyntax(o.IncrementalCrontab) { return errors.New("Invalid incremental backup schedule") } return nil @@ -212,6 +215,7 @@ func (o *CreateOptions) AddFlags(cmd *cobra.Command) { func (o *CreateOptions) SetRequiredFlags(cmd *cobra.Command) { _ = cmd.MarkFlagRequired(FLAG_FULL) + _ = cmd.MarkFlagRequired(FLAG_INCREMENTAL) _ = cmd.MarkFlagRequired(FLAG_ARCHIVE_PATH) _ = cmd.MarkFlagRequired(FLAG_BAK_DATA_PATH) }