From ea0eb66096ddc62758d613e9eae84b9d8b3061dc Mon Sep 17 00:00:00 2001 From: BanceDev Date: Sun, 8 Sep 2024 12:41:18 -0400 Subject: added support for cli args for lua scripts --- .lush/scripts/example.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to '.lush/scripts/example.lua') 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 -- cgit v1.2.3-59-g8ed1b