Add non-interactive installer flag (-y) to finish.nim (#10603) [backport]
This commit is contained in:
parent
6b88ce3384
commit
fd62d24c4c
1 changed files with 21 additions and 4 deletions
|
|
@ -8,6 +8,9 @@ const
|
||||||
mingw = "mingw$1-6.3.0.7z" % arch
|
mingw = "mingw$1-6.3.0.7z" % arch
|
||||||
url = r"https://nim-lang.org/download/" & mingw
|
url = r"https://nim-lang.org/download/" & mingw
|
||||||
|
|
||||||
|
var
|
||||||
|
interactive = true
|
||||||
|
|
||||||
type
|
type
|
||||||
DownloadResult = enum
|
DownloadResult = enum
|
||||||
Failure,
|
Failure,
|
||||||
|
|
@ -38,19 +41,28 @@ proc downloadMingw(): DownloadResult =
|
||||||
if cmd.len > 0:
|
if cmd.len > 0:
|
||||||
if execShellCmd(cmd) != 0:
|
if execShellCmd(cmd) != 0:
|
||||||
echo "download failed! ", cmd
|
echo "download failed! ", cmd
|
||||||
openDefaultBrowser(url)
|
if interactive:
|
||||||
result = Manual
|
openDefaultBrowser(url)
|
||||||
|
result = Manual
|
||||||
|
else:
|
||||||
|
result = Failure
|
||||||
else:
|
else:
|
||||||
if unzip(): result = Success
|
if unzip(): result = Success
|
||||||
else:
|
else:
|
||||||
openDefaultBrowser(url)
|
if interactive:
|
||||||
result = Manual
|
openDefaultBrowser(url)
|
||||||
|
result = Manual
|
||||||
|
else:
|
||||||
|
result = Failure
|
||||||
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
import registry
|
import registry
|
||||||
|
|
||||||
proc askBool(m: string): bool =
|
proc askBool(m: string): bool =
|
||||||
stdout.write m
|
stdout.write m
|
||||||
|
if not interactive:
|
||||||
|
stdout.writeLine "y (non-interactive mode)"
|
||||||
|
return true
|
||||||
while true:
|
while true:
|
||||||
try:
|
try:
|
||||||
let answer = stdin.readLine().normalize
|
let answer = stdin.readLine().normalize
|
||||||
|
|
@ -67,6 +79,9 @@ when defined(windows):
|
||||||
proc askNumber(m: string; a, b: int): int =
|
proc askNumber(m: string; a, b: int): int =
|
||||||
stdout.write m
|
stdout.write m
|
||||||
stdout.write " [" & $a & ".." & $b & "] "
|
stdout.write " [" & $a & ".." & $b & "] "
|
||||||
|
if not interactive:
|
||||||
|
stdout.writeLine $a & " (non-interactive mode)"
|
||||||
|
return a
|
||||||
while true:
|
while true:
|
||||||
let answer = stdin.readLine()
|
let answer = stdin.readLine()
|
||||||
try:
|
try:
|
||||||
|
|
@ -291,4 +306,6 @@ when isMainModule:
|
||||||
when defined(testdownload):
|
when defined(testdownload):
|
||||||
discard downloadMingw()
|
discard downloadMingw()
|
||||||
else:
|
else:
|
||||||
|
if "-y" in commandLineParams():
|
||||||
|
interactive = false
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue