summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-09-21 00:34:29 +0800
committerruki <[email protected]>2017-09-20 21:26:55 +0800
commit4d3fbc3c4027b391b5a2b9fe19b0598450162d05 (patch)
treeae115bf90903628fde0f158bb86a74f83d0b5a89
parent9b3dc3d2a9250be9bfde08fbd3afadd0eb406894 (diff)
add install confirm tips for requires
-rw-r--r--xmake/actions/require/install.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/xmake/actions/require/install.lua b/xmake/actions/require/install.lua
index 764745c33..96fcb44c3 100644
--- a/xmake/actions/require/install.lua
+++ b/xmake/actions/require/install.lua
@@ -98,6 +98,34 @@ function _check_missing_packages(packages)
_g.optional_missing = optional_missing
end
+-- get user confirm
+function _get_confirm(packages)
+
+ -- get confirm
+ local confirm = option.get("yes")
+ if confirm == nil then
+
+ -- show tips
+ cprint("${bright yellow}note: ${default yellow}try to install all required packages?")
+ for _, instance in ipairs(packages) do
+ if (option.get("force") or not instance:exists()) and (#instance:urls() > 0 or instance:script("install")) then
+ print(" -> %s %s", instance:fullname(), instance:version_str() or "")
+ end
+ end
+ cprint("please input: y (y/n)")
+
+ -- get answer
+ io.flush()
+ local answer = io.read()
+ if answer == 'y' or answer == '' then
+ confirm = true
+ end
+ end
+
+ -- ok?
+ return confirm
+end
+
-- install packages
function _install_packages(requires)
@@ -138,6 +166,11 @@ function _install_packages(requires)
end, #packages)
end
+ -- get user confirm
+ if not _get_confirm(packages) then
+ return
+ end
+
-- download remote packages
local waitindex = 0
local waitchars = {'\\', '|', '/', '-'}