From 5322ab95c2d606796243c2918fc9b6614ff9974a Mon Sep 17 00:00:00 2001 From: Andreas Fankhauser hiddenalpha.ch Date: Sat, 15 Oct 2022 15:29:02 +0200 Subject: (file-tpl) Add file template scriptlee.lua --- src/file-templates/scriptlee.lua | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/file-templates/scriptlee.lua diff --git a/src/file-templates/scriptlee.lua b/src/file-templates/scriptlee.lua new file mode 100644 index 0000000..ac46bbb --- /dev/null +++ b/src/file-templates/scriptlee.lua @@ -0,0 +1,60 @@ + +local objectSeal = assert(require("scriptlee").objectSeal) + +local inn, out, log = io.stdin, io.stdout, io.stderr +local mod = {} + + +function mod.getExports()return{ + --doWhatever = mod.doWhatever, +}end + + +function mod.printHelp() + out:write("\n" + .." TODO write this help page\n" + .."\n" + .." Options:\n" + .."\n") +end + + +function mod.parseArgs( this ) + local positionalArgNr = 0 + for iA=1, #_ENV.arg do + local arg = _ENV.arg[iA] + if false then + elseif arg == "--help" then + mod.printHelp() return -1 + elseif not arg:find("^%-%-") then + positionalArgNr = positionalArgNr + 1 + if false then + --elseif positionalArgNr == 1 then + -- this.whatever = arg + else + log:write("Unexpected arg: ".. arg .."\n")return -1 + end + else + log:write("Unexpected arg: ".. arg .."\n")return -1 + end + end + if not this.whatever then log:write("TODO write errmsg here\n")return -1 end + return 0 +end + + +function mod.run( this ) + log:write("[INFO ] TODO impl what the prog should do\n") +end + + +function mod.main() + local this = objectSeal{ + whatever = false, + } + if mod.parseArgs(this) ~= 0 then os.exit(1) end + mod.run(this) +end + + +if debug.getinfo(3)then return mod.getExports()else mod.main()end -- cgit v1.1