summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-05-26 00:57:23 +0800
committerruki <[email protected]>2021-05-27 09:56:31 +0800
commit01542ad5a23b35cccf9ca6abc6fcb33c6512219e (patch)
tree7804f3d04eac2741b2e8d1371cc2a18c4399bd4d
parentcabfdf44c5b08ad2dfeb425eb5e372cbff6c37fe (diff)
add get confirm stub from 3rd
-rw-r--r--xmake/core/base/utils.lua30
-rw-r--r--xmake/modules/private/action/require/impl/install_packages.lua19
2 files changed, 36 insertions, 13 deletions
diff --git a/xmake/core/base/utils.lua b/xmake/core/base/utils.lua
index 4071490f5..c1b78af4d 100644
--- a/xmake/core/base/utils.lua
+++ b/xmake/core/base/utils.lua
@@ -314,18 +314,18 @@ function utils.confirm(opt)
local description = opt.description or ""
-- get confirm result
- local confirm = option.get("yes") or option.get("confirm")
- if type(confirm) == "string" then
- confirm = confirm:lower()
- if confirm == "d" or confirm == "def" then
- confirm = default
+ local result = option.get("yes") or option.get("confirm")
+ if type(result) == "string" then
+ result = result:lower()
+ if result == "d" or result == "def" then
+ result = default
else
- confirm = nil
+ result = nil
end
end
-- get user confirm
- if confirm == nil then
+ if result == nil then
-- show tips
if type(description) == "function" then
@@ -333,16 +333,20 @@ function utils.confirm(opt)
else
utils.cprint("${bright color.warning}note: ${clear}%s (pass -y or --confirm=y/n/d to skip confirm)?", description)
end
- utils.cprint("please input: ${bright}%s${clear} (y/n)", default and "y" or "n")
-- get answer
- io.flush()
- confirm = option.boolean((io.read() or "false"):trim())
- if type(confirm) ~= "boolean" then
- confirm = default
+ if opt.answer then
+ result = opt.answer()
+ else
+ utils.cprint("please input: ${bright}%s${clear} (y/n)", default and "y" or "n")
+ io.flush()
+ result = option.boolean((io.read() or "false"):trim())
+ if type(result) ~= "boolean" then
+ result = default
+ end
end
end
- return confirm
+ return result
end
function utils.table(data, opt)
diff --git a/xmake/modules/private/action/require/impl/install_packages.lua b/xmake/modules/private/action/require/impl/install_packages.lua
index e2d97e2f3..ac3a16f6c 100644
--- a/xmake/modules/private/action/require/impl/install_packages.lua
+++ b/xmake/modules/private/action/require/impl/install_packages.lua
@@ -46,6 +46,10 @@ function _sort_packages_urls(packages)
end
end
+-- get user confirm from 3rd package sources
+function _get_confirm_from_3rd(packages)
+end
+
-- get user confirm
function _get_confirm(packages)
@@ -100,7 +104,22 @@ function _get_confirm(packages)
end
end
end
+ end, answer = function ()
+ cprint("please input: ${bright}y${clear} (y/n/more)")
+ io.flush()
+ return (io.read() or "false"):trim()
end})
+
+ -- more? get confirm from 3rd package sources
+ if confirm == "more" or confirm == "m" then
+ return _get_confirm_from_3rd(packages)
+ end
+
+ -- get confirm result
+ confirm = option.boolean(confirm)
+ if type(confirm) ~= "boolean" then
+ confirm = true
+ end
return confirm
end