diff options
| author | ruki <[email protected]> | 2023-02-01 00:53:04 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-02-01 00:53:04 +0800 |
| commit | 8fcfa349daf5add9d1be7ab5091eab4c5b89ea76 (patch) | |
| tree | 7dd4a72e1e7d24539d26ec43269f4c62cb649771 /xmake/plugins/check/main.lua | |
| parent | 93aa9ca807fd263059df50406abe033f24846b31 (diff) | |
do check
Diffstat (limited to 'xmake/plugins/check/main.lua')
| -rw-r--r-- | xmake/plugins/check/main.lua | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/xmake/plugins/check/main.lua b/xmake/plugins/check/main.lua index 3e411ff54..e2479526d 100644 --- a/xmake/plugins/check/main.lua +++ b/xmake/plugins/check/main.lua @@ -23,6 +23,7 @@ import("core.base.option") import("core.base.text") import("checker") +-- show checkers list function _show_list() local tbl = {align = 'l', sep = " "} local checkers = checker.checkers() @@ -39,6 +40,7 @@ function _show_list() cprint(text.table(tbl)) end +-- show checker information function _show_info(name) local checkers = checker.checkers() local info = checkers[name] @@ -50,10 +52,31 @@ function _show_info(name) end end +-- do check +function _check(group_or_name, arguments) + local checked_checkers = {} + local checkers = checker.checkers() + if checkers[group_or_name] then + table.insert(checked_checkers, group_or_name) + else + for name, _ in table.orderpairs(checkers) do + if name:startswith(group_or_name .. ".") then + table.insert(checked_checkers, name) + end + end + end + assert(#checked_checkers > 0, "checker(%s) not found!", group_or_name) + for _, name in ipairs(checked_checkers) do + import("checkers." .. name, {anonymous = true})(arguments) + end +end + function main() if option.get("list") then - return _show_list() + _show_list() elseif option.get("info") then - return _show_info(option.get("info")) + _show_info(option.get("info")) + elseif option.get("checkers") then + _check(option.get("checkers"), option.get("arguments")) end end |
