diff options
| author | Gly <[email protected]> | 2022-12-22 01:22:05 +0100 |
|---|---|---|
| committer | Gly <[email protected]> | 2022-12-22 01:22:05 +0100 |
| commit | 524a23ae6a0a5fcdd23c8c32a52ab62bcd07830b (patch) | |
| tree | b7b88ebb74fc8f2619f21971a2729f2d0fc8338b /xmake/modules/private/utils/complete.lua | |
| parent | c3ca3ff48a2dfb9dd15af62102af539dec58c385 (diff) | |
embed candid info into object
Diffstat (limited to 'xmake/modules/private/utils/complete.lua')
| -rw-r--r-- | xmake/modules/private/utils/complete.lua | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/xmake/modules/private/utils/complete.lua b/xmake/modules/private/utils/complete.lua index 09f0b8ca6..dd396572e 100644 --- a/xmake/modules/private/utils/complete.lua +++ b/xmake/modules/private/utils/complete.lua @@ -32,11 +32,10 @@ local use_spaces = true local no_key = false local reenter = false -function _print_candidate(is_complate, ...) - local candidate = format(...) - if candidate and #candidate ~= 0 then - printf(candidate) - if use_spaces and is_complate then +function _print_candidate(candidate) + if candidate.value and #candidate.value ~= 0 then + printf(candidate.value) + if use_spaces and candidate.is_complete then print(" ") else print("") @@ -44,12 +43,12 @@ function _print_candidate(is_complate, ...) end end -function _print_candidates(is_complate, candidates) +function _print_candidates(candidates) if to_json then - printf("%s", json.encode(candidates)) + print(json.encode(candidates)) else for _, v in ipairs(candidates) do - _print_candidate(is_complate, "%s", v.value) + _print_candidate(v) end end end @@ -89,9 +88,9 @@ end function _complete_task(tasks, name) local found_candidates = {} for i, v in ipairs(_find_candidates((table.keys(tasks)), name)) do - table.insert(found_candidates, { value = v, description = tasks[v].description }) + table.insert(found_candidates, { value = v, is_complete = true, description = tasks[v].description }) end - _print_candidates(has_candidate, found_candidates) + _print_candidates(found_candidates) return #found_candidates > 0 end |
