diff options
| author | ruki <[email protected]> | 2026-06-18 21:33:10 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-06-18 21:33:10 +0800 |
| commit | e782a2fbb9815e217671216e218fb3017f3cf60b (patch) | |
| tree | 527e8d557370d6a9cb2303ffdd317444f7659de6 /xmake/plugins/lua | |
| parent | 9b8df1e3c6bf7aa841c3c62f8f80d5016690367b (diff) | |
| parent | 6aeb1e3fef16f55f6ff20e60bb48ddded9c90faf (diff) | |
Merge pull request #7608 from xmake-io/format
format menus
Diffstat (limited to 'xmake/plugins/lua')
| -rw-r--r-- | xmake/plugins/lua/xmake.lua | 104 |
1 files changed, 42 insertions, 62 deletions
diff --git a/xmake/plugins/lua/xmake.lua b/xmake/plugins/lua/xmake.lua index dee1707b6..2c56c637e 100644 --- a/xmake/plugins/lua/xmake.lua +++ b/xmake/plugins/lua/xmake.lua @@ -18,69 +18,49 @@ -- @file xmake.lua -- --- define task task("lua") - - -- set category set_category("plugin") - - -- on run on_run("main") - - -- set menu set_menu { - -- usage - usage = "xmake lua|l [options] [script] [arguments]" - - -- description - , description = "Run the lua script." - - -- xmake l - , shortname = 'l' - - -- options - , options = - { - - {'l', "list" , "k" , nil , "List all scripts." } - , {'c', "command" , "k" , nil , "Run script as command" } - , {'d', "deserialize" , "kv" , nil , "Deserialize arguments starts with given prefix" } - , {nil, "stdin" , "k" , nil , "Run script from stdin", - "e.g.", - " - echo 'print(\"hello\")' | xmake lua --stdin", - " - cat script.lua | xmake lua --stdin" - } - , {nil, "script" , "v" , nil , "Run the given lua script name, file or module and enter interactive mode if no given script.", - "e.g.", - " - xmake lua (enter interactive mode)", - " - xmake lua /tmp/script.lua", - " - xmake lua echo 'hello xmake'", - " - xmake lua core.xxx.xxx", - " - xmake lua -c 'print(...)' hello xmake!" - , values = function (complete, opt) - if not complete or opt.command or opt.list then - return - end - local list = import("main.scripts")() - if list and complete then - local result = {} - for _, item in ipairs(list) do - if item:startswith(complete) then - table.insert(result, item) - end - end - if #result > 0 then - return result - end - end - -- we just return nil and fallback to system autocomplete - -- it will complete file path, e.g. `xmake l scripts/test.lua` - end } - , {nil, "arguments" , "vs" , nil , "The script arguments, use '--deserialize' option to enable deserializing.", - "e.g.", - " - xmake lua -d@ lib.detect.find_tool tar @{version=true}" } - } - } - - - + usage = "xmake lua|l [options] [script] [arguments]", + description = "Run the lua script.", + shortname = 'l', + options = { + {'l', "list", "k", nil, "List all scripts."}, + {'c', "command", "k", nil, "Run script as command"}, + {'d', "deserialize", "kv", nil, "Deserialize arguments starts with given prefix"}, + {nil, "stdin", "k", nil, "Run script from stdin", + "e.g.", + " - echo 'print(\"hello\")' | xmake lua --stdin", + " - cat script.lua | xmake lua --stdin"}, + {nil, "script", "v", nil, "Run the given lua script name, file or module and enter interactive mode if no given script.", + "e.g.", + " - xmake lua (enter interactive mode)", + " - xmake lua /tmp/script.lua", + " - xmake lua echo 'hello xmake'", + " - xmake lua core.xxx.xxx", + " - xmake lua -c 'print(...)' hello xmake!", + values = function (complete, opt) + if not complete or opt.command or opt.list then + return + end + local list = import("main.scripts")() + if list and complete then + local result = {} + for _, item in ipairs(list) do + if item:startswith(complete) then + table.insert(result, item) + end + end + if #result > 0 then + return result + end + end + -- we just return nil and fallback to system autocomplete + -- it will complete file path, e.g. `xmake l scripts/test.lua` + end}, + {nil, "arguments", "vs", nil, "The script arguments, use '--deserialize' option to enable deserializing.", + "e.g.", + " - xmake lua -d@ lib.detect.find_tool tar @{version=true}"}, + } + } |
