mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-30 15:35:33 +08:00
Signed-off-by: longjiquan <jiquan.long@zilliz.com> Signed-off-by: longjiquan <jiquan.long@zilliz.com>
43 lines
780 B
Go
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)
|
|
}
|
|
}
|