Jiquan Long b0a12116c8
Fix meta migration tool (#19814)
Signed-off-by: longjiquan <jiquan.long@zilliz.com>

Signed-off-by: longjiquan <jiquan.long@zilliz.com>
2022-10-17 15:07:25 +08:00

43 lines
780 B
Go

package console
import (
"os"
)
func ExitWithOption(opts ...ExitOption) {
c := defaultExitConfig()
c.apply(opts...)
if c.abnormal {
Error(c.msg)
} else {
Success(c.msg)
}
os.Exit(c.code)
}
func AbnormalExit(backupFinished bool, msg string) {
opts := []ExitOption{WithAbnormalExit(), WithMsg(msg)}
if backupFinished {
opts = append(opts, WithExitCode(FailButBackupFinished))
} else {
opts = append(opts, WithExitCode(BackupUnfinished))
}
ExitWithOption(opts...)
}
func AbnormalExitIf(err error, backupFinished bool) {
if err != nil {
AbnormalExit(backupFinished, err.Error())
}
}
func NormalExit(msg string) {
ExitWithOption(WithExitCode(NormalCode), WithMsg(msg))
}
func NormalExitIf(success bool, msg string) {
if success {
NormalExit(msg)
}
}