diff options
| author | Jérôme Leclercq <[email protected]> | 2022-07-05 12:56:21 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-07-05 12:56:21 +0200 |
| commit | 6e7f78a7ba89f868cd97e9ebd1362970e52c0bf6 (patch) | |
| tree | 037f53b555b01723a335d1b3b63322082f4f889c | |
| parent | 8595c98806076a08758303837a7804115b80a666 (diff) | |
xmake run: Improve error message when target doesn't exist
| -rw-r--r-- | xmake/actions/run/main.lua | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua index 6daae3076..841df4780 100644 --- a/xmake/actions/run/main.lua +++ b/xmake/actions/run/main.lua @@ -148,7 +148,24 @@ function _check_targets(targetname, group_pattern) -- get targets local targets = {} if targetname then - local target = assert(project.target(targetname), "%s not found!", targetname) + local target = project.target(targetname) + if not target then + -- check if the name is part of other target to help + local possible_targetnames = {} + for _, target in ipairs(project.ordertargets()) do + if target:name():lower():find(targetname:lower()) then + table.insert(possible_targetnames, target:name()) + end + end + + local err = targetname .. " is not a valid target name for this project" + if #possible_targetnames > 0 then + err = err .. "\ndid you mean:\n - " .. table.concat(possible_targetnames, '\n - ') + end + + raise(err) + end + table.insert(targets, target) else for _, target in ipairs(project.ordertargets()) do |
