diff options
author | Andreas Fankhauser hiddenalpha.ch | 2022-10-15 15:29:02 +0200 |
---|---|---|
committer | Andreas Fankhauser hiddenalpha.ch | 2022-10-15 15:29:02 +0200 |
commit | 5322ab95c2d606796243c2918fc9b6614ff9974a (patch) | |
tree | 62ba9907cae23e4f10c85a1fecd4e33c3bbe5c93 | |
parent | c4915b3e04a4acb424eafd3d815ee8bd848badd8 (diff) | |
download | dotfiles-5322ab95c2d606796243c2918fc9b6614ff9974a.zip dotfiles-5322ab95c2d606796243c2918fc9b6614ff9974a.tar.gz |
(file-tpl) Add file template scriptlee.lua
-rw-r--r-- | src/file-templates/scriptlee.lua | 60 |
1 files changed, 60 insertions, 0 deletions
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 |