提交 2a1c5fd1 编写于 作者: LinuxSuRen's avatar LinuxSuRen

Add prompt confirm for restart

上级 9028069b
......@@ -7,24 +7,29 @@ import (
"log"
"net/http"
"github.com/AlecAivazis/survey"
"github.com/spf13/cobra"
)
type RestartOptions struct {
}
func init() {
rootCmd.AddCommand(restartCmd)
}
//curl -X POST http://localhost:8080/jenkins/safeRestart
var restartCmd = &cobra.Command{
Use: "restart",
Short: "Restart your Jenkins",
Long: `Restart your Jenkins`,
Run: func(cmd *cobra.Command, args []string) {
crumb, config := getCrumb()
confirm := false
prompt := &survey.Confirm{
Message: fmt.Sprintf("Are you sure to restart Jenkins %s?", config.URL),
}
survey.AskOne(prompt, &confirm)
if !confirm {
return
}
api := fmt.Sprintf("%s/safeRestart", config.URL)
req, err := http.NewRequest("POST", api, nil)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册