aboutsummaryrefslogtreecommitdiffstats
path: root/.lush/scripts/example.lua
diff options
context:
space:
mode:
authorGravatar BanceDev 2024-09-08 12:41:18 -0400
committerGravatar BanceDev 2024-09-08 12:41:18 -0400
commitea0eb66096ddc62758d613e9eae84b9d8b3061dc (patch)
tree9be2d6cbda389d174554d05481797a2b107ac0f4 /.lush/scripts/example.lua
parentadded --version flag (diff)
added support for cli args for lua scripts
Diffstat (limited to '')
-rw-r--r--.lush/scripts/example.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/.lush/scripts/example.lua b/.lush/scripts/example.lua
index 9cf3c96..ffd04c1 100644
--- a/.lush/scripts/example.lua
+++ b/.lush/scripts/example.lua
@@ -23,6 +23,15 @@ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
print("Welcome to Lunar Shell scripting")
+-- command line args can be passed to lua programs
+-- done like so: example.lua arg1 arg2 ...
+-- args can be read using the global args tables
+if args ~= nil then
+ for i = 1, #args do
+ print(args[i])
+ end
+end
+
-- exec can be used to run any command line prompt
-- this method is much more native than using os.execute and is the recommended function
-- it also returns a boolean on if the command executed successfully