summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaikari <[email protected]>2026-01-31 16:51:38 +0300
committerSaikari <[email protected]>2026-01-31 16:51:38 +0300
commit5e59fa1d59486438337290e3d528561791843f7c (patch)
tree1580fd18c585f9b1da20abba6c365d262f9ae4c3
parentfa2d696a26d1e5738a38241e02908f6a3d8c52b8 (diff)
refactor: improve stdin command handling with detailed usage examples
-rw-r--r--xmake/core/base/os.lua5
-rw-r--r--xmake/plugins/lua/xmake.lua16
2 files changed, 19 insertions, 2 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index 12bc30c1d..9332f2c61 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -1187,7 +1187,10 @@ function os.isexec(filepath)
end
end
elseif os.isfile(filepath) then
- return os._access(filepath, "x")
+ if os._access then
+ return os._access(filepath, "x")
+ end
+ return true
end
return false
end
diff --git a/xmake/plugins/lua/xmake.lua b/xmake/plugins/lua/xmake.lua
index c8ebc8ba3..527ecb19e 100644
--- a/xmake/plugins/lua/xmake.lua
+++ b/xmake/plugins/lua/xmake.lua
@@ -45,7 +45,21 @@ task("lua")
{'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, "from-stdin" , "k" , nil , "Run script from stdin" }
+ , {nil, "from-stdin" , "k" , nil , "Run script from stdin",
+ "e.g.",
+ " - CMD",
+ " - Single: echo print('hello') | xmake lua --from-stdin",
+ " - Multiline: (echo print('1') && echo print('2')) | xmake lua --from-stdin",
+ " - File: type script.lua | xmake lua --from-stdin",
+ " - PWSH",
+ " - Single: Write-Output 'print(\"hello\")' | xmake lua --from-stdin",
+ " - Multiline: Write-Output \"print('1')`nprint('2')\" | xmake lua --from-stdin",
+ " - File: Get-Content script.lua | xmake lua --from-stdin",
+ " - SH",
+ " - Single: echo 'print(\"hello\")' | xmake lua --from-stdin",
+ " - Multiline: (echo 'print(\"1\")'; echo 'print(\"2\")') | xmake lua --from-stdin",
+ " - File: cat script.lua | xmake lua --from-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)",