magic/cmd/acme_sh/read.go
2026-03-28 19:25:12 +08:00

39 lines
948 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package acme_sh
import (
"context"
"fmt"
"strings"
"gitea.micah.wiki/pandora/naive/pkg/stdinx"
"gitea.micah.wiki/pandora/magic/config"
)
func ReadIsNew(ctx context.Context) (bool, error) {
isNewFlag, err := stdinx.ReadStr(ctx, fmt.Sprintf("*** 新增 or 更新:(新增: Y; 更新: N;"))
if err != nil {
return false, err
}
if strings.EqualFold(isNewFlag, "y") {
return true, nil
}
return false, nil
}
func ReadCurrentAcmeSh(ctx context.Context, conf *config.Config) (*config.AcmeSh, error) {
total := len(conf.AcmeShs)
for i, acmeSh := range conf.AcmeShs {
check, err := stdinx.ReadStr(ctx, fmt.Sprintf("*** 请确认是否需要生成当前域名`%s`(%d/%d):(是: Y; 否: N;", acmeSh.Domain, i+1, total))
if err != nil {
return nil, err
}
if strings.EqualFold(check, "y") {
return acmeSh, nil
}
}
return nil, fmt.Errorf("未选择任何需要生成的域名,请编辑配置后,再运行")
}