|
|
@ -21,8 +21,10 @@ import (
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
"os/exec"
|
|
|
|
"regexp"
|
|
|
|
"regexp"
|
|
|
|
|
|
|
|
"runtime"
|
|
|
|
"strconv"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"syscall"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -985,3 +987,45 @@ func (this suncli) WriteCmd(cmdstr string) {
|
|
|
|
this.infile.Write([]byte(cmdstr + "\n"))
|
|
|
|
this.infile.Write([]byte(cmdstr + "\n"))
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (this suncli) ExitCode() int {
|
|
|
|
|
|
|
|
return this.cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func MsgBox(text, defaults string) string {
|
|
|
|
|
|
|
|
var input string
|
|
|
|
|
|
|
|
input = defaults
|
|
|
|
|
|
|
|
fmt.Print(text)
|
|
|
|
|
|
|
|
fmt.Scanln(&input)
|
|
|
|
|
|
|
|
return strings.TrimSpace(input)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func MessageBox(text, defaults string) string {
|
|
|
|
|
|
|
|
fmt.Print(text)
|
|
|
|
|
|
|
|
inputReader := bufio.NewReader(os.Stdin)
|
|
|
|
|
|
|
|
str, _ := inputReader.ReadString('\n')
|
|
|
|
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
|
|
|
|
str = str[0 : len(str)-2]
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
str = str[0 : len(str)-1]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if str == "" {
|
|
|
|
|
|
|
|
str = defaults
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return strings.TrimSpace(str)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func YesNo(text string, defaults bool) bool {
|
|
|
|
|
|
|
|
res := strings.ToUpper(MsgBox(text, ""))
|
|
|
|
|
|
|
|
if res == "" {
|
|
|
|
|
|
|
|
return defaults
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
res = res[0:1]
|
|
|
|
|
|
|
|
if res == "Y" {
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
} else if res == "N" {
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return defaults
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|