{"id":13495228,"url":"https://github.com/tongson/LadyLua","last_synced_at":"2025-03-28T16:31:57.344Z","repository":{"id":48506494,"uuid":"352582998","full_name":"tongson/LadyLua","owner":"tongson","description":"Single executable(static), batteries included, Lua 5.1 interpreter.","archived":false,"fork":false,"pushed_at":"2021-09-12T10:44:55.000Z","size":2394,"stargazers_count":84,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-08-01T19:54:27.056Z","etag":null,"topics":["lua","scripting"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tongson.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-29T09:15:35.000Z","updated_at":"2024-04-14T06:41:00.000Z","dependencies_parsed_at":"2022-09-04T15:23:57.636Z","dependency_job_id":null,"html_url":"https://github.com/tongson/LadyLua","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tongson%2FLadyLua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tongson%2FLadyLua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tongson%2FLadyLua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tongson%2FLadyLua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tongson","download_url":"https://codeload.github.com/tongson/LadyLua/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222395775,"owners_count":16977622,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lua","scripting"],"created_at":"2024-07-31T19:01:32.712Z","updated_at":"2024-10-31T10:30:48.723Z","avatar_url":"https://github.com/tongson.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"= LadyLua\n:toc:\n:toc-placement!:\n\nSingle static executable, batteries-included, Lua 5.1 interpreter. A fat https://github.com/yuin/gopher-lua[GopherLua] amalgamation of modules in Go and Lua.\n\ntoc::[]\n\n== Changelog\n\nNext release: *0.11.0 Tarot Cruncher* +\n+ `string.trim` fix +\n+ New module `csv` +\n+ Take STDIN as code +\n\nCurrent release: *0.10.0 Black Future* +\n+ Aliases: `list:push` `list:pop` +\n+ Aliases: `queue:push` `queue:pop` `queue:iterator` +\n+ `tuple` module fixes and enhancements +\n+ Renamed `tuple:elements` to `tuple:iterator` +\n+ Renamed `bimap` module to `map` +\n+ Renamed `deque` module to `queue` +\n+ New module: `state` +\n+ New module: `graph` +\n+ New module: `object` +\n+ New module: `ssh_config` +\n+ New module: `date` +\n+ New functions: `refmt.toml_to_json` and `refmt.json_to_toml` +\n+ Removed `rr` module +\n\nOld releases: +\n*0.9.0 Scared Shrapnel* +\n+ Loading plain Lua source is now done through `package.loaders` +\n+ Faster VM startup time; From 18ms to \u003c1ms in a test machine +\n+ Now a module to support ./cmd builds +\n+ Easier standalone programs +\n+ Added `crypto.random` +\n+ Added `crypto.fast_random` +\n+ Removed `kapow` module +\n+ New module: `guard` +\n+ New module: `deque` +\n+ New module: `bimap` +\n+ New module: `tuple` +\n+ New module: `argparse` +\n+ New global function for extending modules: `extend` +\n+ Moved `exec.cmd` and `exec.run` to `exec` extensions module +\n+ Moved `json.array` and `json.object` to `json` extensions module +\n+ Moved `string` extensions to separate extensions module +\n+ Added `table.clone` +\n+ Added `table.read_only` +\n+ Bug fix: `list` +\n+ gopher-lua fixes for `pcall`, `select`, `#` operator, and `string.gsub` +\n+ Add `bitcask.open` configuration argument for maximum value size +\n\n*0.8.0 Freckled Serpent* +\n+ New setting for exec.*; timeout in seconds +\n+ New json functions, array and object iterators +\n+ New function: os.sleep +\n+ Removed password module +\n+ Replaced kapow.not_allowed with kapow.unprocessable +\n+ Removed html module +\n+ Stripped 1MiB by removing password and html modules +\n+ New module: list +\n\n*0.7.0 Negligent Clamshell* +\n+ New module: bitcask +\n+ New function: logger.time() +\n+ New DSL module: Lopper +\n+ Removed inspect module +\n+ New function: crypto.valid_hmac +\n+ DSL modules no longer embedded +\n+ New module: refmt +\n+ New module: rr +\n+ Rename module uid to ksuid +\n+ New module: uuid +\n+ New module: ulid +\n+ New function string.split +\n+ New function string.splitv +\n+ New function string.trim_end +\n+ New function string.trim_start +\n+ New function string.contains +\n+ table.find is now recursive +\n+ New function os.outbound_ip +\n+ New function password.strength +\n\n*0.6.0 Gummy Mastiff* +\n+ New module: telegram +\n+ New module: pushover +\n+ New module: slack +\n+ New module: logger +\n+ New module: fsnotify +\n+ redis: converted to object:method style +\n+ buildah: New NOTIFY settings +\n\n*0.5.3 Epidural Dollop* +\n+ buildah: Consolidate APK command +\n\n*0.5.2 Yelling Petunia* +\n+ buildah: Removed default cmd config in ENTRYPOINT() +\n+ buildah: Removed default arguments from MKDIR(), COPY(), ADD() +\n\n*0.5.1 Failed Siesta* +\n+ Fix buildah PUSH() +\n\n*0.5.0 Surplus Siesta* +\n+ New DSL module \"buildah\" +\n+ New module \"lz4\" +\n+ Selene configuration +\n+ Removed redundant string.line_to_list() +\n+ Added string.to_map() +\n+ Add fourth return value for exec.command +\n\n\n\n++++\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"ll.svg?raw=true\"/\u003e\n\u003c/p\u003e\n++++\n\n== Why?\nLua is a good language but no one wants to use it for general-purpose scripting. Complaints are 1-based indexing and missing libraries. The latter is a valid concern. The 5.2+ split also does not help. I was convinced that GopherLua would be a good base for a kitchen-sink interpreter. Writing wrappers for the vast selection of Go packages would be a breeze.\n\n== Reference\nSince GopherLua is an implementation of Lua 5.1, you can use the official Lua 5.1 reference manual: https://www.lua.org/manual/5.1/manual.html[Lua 5.1 Manual]. Other resources are also useful just make sure they do not target 5.2+ versions. Search for PDFs of Lua 5.1 cheatsheets. The Learn in in 15 minutes series also has an entry for http://tylerneylon.com/a/learn-lua/[Lua].\n\n== Standalone programs\n\nSee this -\u003e https://github.com/tongson/patch_tuesday[patch_tuesday] Github repository for an example of a LadyLua standalone program.\n\n== Modules\nCheck the `docs` directory for more information about these modules.\n\n=== Available modules\n\n[options=\"header\",width=\"88%\"]\n|===\n|Module      |Global |Type |Source           |License\n|argparse    |N      |Lua  |argparse         |MIT\n|bimap       |N      |Lua  |cw-lua           |MIT\n|bitcask     |N      |Go   |                 |MIT\n|crypto      |N      |Go   |gluacrypto       |MIT\n|csv         |N      |Lua  |ftcsv            |MIT\n|date        |N      |Lua  |date             |MIT\n|deque       |N      |Lua  |cw-lua           |MIT\n|exec        |Y      |Go   |                 |MIT\n|fmt         |N      |Lua  |                 |MIT\n|fs          |Y      |Go   |gopher-lfs       |Unlicense\n|fsnotify    |N      |Go   |                 |MIT\n|graph       |N      |Lua  |tsort            |BSD2\n|guard       |N      |Lua  |guard            |MIT\n|http        |N      |Go   |gluahttp         |MIT\n|json        |N      |Go   |gopher-json      |Unlicense\n|ksuid       |N      |Go   |                 |MIT\n|list        |N      |Lua  |linked_list.lua  |MIT\n|logger      |N      |Go   |                 |MIT\n|lz4         |N      |Go   |                 |BSD3\n|mysql       |N      |Go   |gluasql          |MIT\n|object      |N      |Lua  |object           |Unlicense\n|pushover    |N      |Go   |                 |MIT\n|redis       |N      |Go   |                 |MIT\n|refmt       |N      |Go   |                 |MIT\n|rr          |N      |Go   |                 |MIT\n|slack       |N      |Go   |                 |MIT\n|ssh_config  |N      |Go   |ssh_config       |MIT\n|state       |N      |Lua  |ahsm             |MIT\n|telegram    |N      |Go   |                 |MIT\n|template    |N      |Lua  |etlua            |MIT\n|test        |N      |Lua  |u-test           |MIT\n|tuple       |N      |Lua  |tuple.lua        |MIT\n|ulid        |N      |Go   |                 |APL2\n|uuid        |N      |Go   |                 |MPL2\n|===\n\n:note-caption: :information_source:\n[NOTE]\n====\nIf it says *N* in the *Global* field, you need to `require()` it. +\nModules that are type `Go` should be loaded through `ll.PreloadGo`\n====\n\n=== Extensions\nThese extensions extends a global namespace or module.\n\nLoad by adding a call to `extend`. Example:\n----\nextend(\"json\")\n----\n\n[options=\"header\",width=\"88%\"]\n|===\n|Extension\n|table\n|string\n|exec\n|json\n|===\n\n=== DSL modules\nLua modules are single file Lua source that are loaded from the current working directory.\n\n[options=\"header\",width=\"50%\"]\n|===\n|Module\n|buildah\n|lopper\n|===\n\n== Documentation and Testing\nTests are in the `tests` directory. We are using `u-test`. Within the test code is the documentation in AsciiDoc. Generated docs are in the `docs` directory. Check the `scripts/docs` directory for the command line to generate the docs.\n\n== Uses\nBesides general purpose scripting, a more specific use for me right now is using Lua for writing web apps. You can write it dynamic style like PHP but instead you have Lua. Another idea is hooking Go packages that interface with DevOps things. Instead of YAML you can program DevOps tools in Lua.\n\n=== SAMPLE: shell script converted to Lua\nCheck this https://github.com/tongson/LadyLua/commit/0a1949060627fbee309e5549f0d00d0299ace3de?branch=0a1949060627fbee309e5549f0d00d0299ace3de\u0026diff=split[diff] to get a feel of the conversion from a shell script to Lua.\n\n=== Declarative scripting\nUsing metatables you can hide the plumbing and present a declarative interface. The following snippet can be found under the `scripts` directory. It is used to run the MariaDB container under systemd for testing the in-tree `mysql` module.\n\n----\nrequire('podman'){\n  NAME = 'mariadb';\n  URL  = 'docker://docker.io/library/mariadb';\n  TAG  = '10.5';\n  CPUS = '1';\n  UNIT = require 'systemd.mariadb';\n  DIR  = '/srv/podman/mariadb';\n  always_update      = false;\n  overwrite_password = false;\n}\n----\n\n=== DSL modules\nInstead of HCL or Dockerfile instructions you can possibly abstract subsystems with Lua. See the `buildah` module for an example of a DSL module.\n\n== FAQ\n\n=== Why not base off Lua 5.2+?\n\nSticking with 5.1 gets you a _finished_ language. For general purpose scripting, the 5.2+ feature are not really useful. You also have access to a significant collection of plain Lua modules. Excellent tools from the Roblox side like Selene and Stylua still works with 5.1.\n\n== Statistics and numbers\n|=======================\n|Tests |188/188\n|Static executable bytes |9007104\n|=======================\n\n=== Bloat tracker\nModules that adds significant bloat to the interpreter. If you don't need these maybe you can trim them from your fork. Just estimates though. The later added modules may have dependencies shared with earlier modules.\n\n|======\n|http |3-4MiB\n|redis |800KiB\n|mysql |500KiB\n|slack |230KiB\n|refmt |300KiB\n|======\n\n=== Benchmark\nWonder how it compares to PUC-Rio Lua 5.1.5 and LuaJIT2?\n\nHere's a benchmark for object access time. Check the `bench/` directory for the code. The results are from the default 100M runs. GopherLua is fast enough for unconvoluted work. It also demonstrates that LuaJIT is too smart for these benchmarks.\n\n.LadyLua\n|=======================\n|68.998712974 |Standard (solid)\n|81.63775507999999 |Standard (metatable)\n|73.37786640899998 |Object using closures (PiL 16.4)\n|48.266743347000016 |Object using closures (noself)\n|46.76494954999998 |Direct Access\n|26.742789899 |Local Variable\n|=======================\n\n.Lua 5.1.5\n|=======================\n|12.906285 |Standard (solid)\n|13.649843 |Standard (metatable)\n|13.294447 |Object using closures (PiL 16.4)\n|9.024326  |Object using closures (noself)\n|5.618169  |Direct Access\n|1.76135   |Local Variable\n|=======================\n\n.LuaJIT 2.1\n|=======================\n|0.200721  |Standard (solid)\n|0.200649  |Standard (metatable)\n|0.200672  |Object using closures (PiL 16.4)\n|0.200635  |Object using closures (noself)\n|0.200627  |Direct Access\n|0.200628  |Local Variable\n|=======================\n\nBefore you go disabling function inlining to reduce the executable size; here are the benchmarks for it.\n\n.GopherLua (disabled function inlining)\n|=======================\n|97.82842299|Standard (solid)\n|117.51864293899999|Standard (metatable)\n|103.283447037|Object using closures (PiL 16.4)\n|66.51865570900003|Object using closures (noself)\n|69.64288394199997|Direct Access\n|37.33177725300004|Local Variable\n|=======================\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftongson%2FLadyLua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftongson%2FLadyLua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftongson%2FLadyLua/lists"}