47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package nginx
|
||
|
||
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 ReadCurrent(ctx context.Context, conf *config.Config) (*config.Nginx, error) {
|
||
total := len(conf.Nginx)
|
||
for i, nginx := range conf.Nginx {
|
||
check, err := stdinx.ReadStr(ctx, fmt.Sprintf("*** 请确认是否需要生成当前域名`%s`(%d/%d):(是: Y; 否: N;)", nginx.Domain, i+1, total))
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
if strings.EqualFold(check, "y") {
|
||
return nginx, nil
|
||
}
|
||
}
|
||
return nil, fmt.Errorf("未选择任何需要生成的域名,请编辑配置后,再运行")
|
||
}
|
||
|
||
func ReadRestart(ctx context.Context) bool {
|
||
restartFlag, err := stdinx.ReadStr(ctx, "*** 是否需要重启nginx(确认:Y or Yes,按其他任意键不重启)")
|
||
if err != nil {
|
||
return false
|
||
}
|
||
return strings.EqualFold(restartFlag, "yes") || strings.EqualFold(restartFlag, "y")
|
||
}
|