{"id":22362694,"url":"https://github.com/wolfulus/flatt","last_synced_at":"2026-02-14T13:32:52.902Z","repository":{"id":57238065,"uuid":"467219054","full_name":"WoLfulus/flatt","owner":"WoLfulus","description":" Flatbuffers scriptable code generation tool","archived":false,"fork":false,"pushed_at":"2025-03-28T02:45:07.000Z","size":14250,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-26T23:43:04.870Z","etag":null,"topics":["c-plus-plus","code-generation","codegen","cpp","flatbuffer","flatbuffers","inja","jinja","lua","protobuf","reflection","template"],"latest_commit_sha":null,"homepage":"","language":"C++","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/WoLfulus.png","metadata":{"files":{"readme":"README.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-07T18:47:48.000Z","updated_at":"2024-09-27T18:16:57.000Z","dependencies_parsed_at":"2024-09-06T03:16:00.895Z","dependency_job_id":"c1b0d6f3-d90b-4e53-8c90-22e01ea3d041","html_url":"https://github.com/WoLfulus/flatt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/WoLfulus/flatt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WoLfulus%2Fflatt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WoLfulus%2Fflatt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WoLfulus%2Fflatt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WoLfulus%2Fflatt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WoLfulus","download_url":"https://codeload.github.com/WoLfulus/flatt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WoLfulus%2Fflatt/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267882833,"owners_count":24160214,"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","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["c-plus-plus","code-generation","codegen","cpp","flatbuffer","flatbuffers","inja","jinja","lua","protobuf","reflection","template"],"created_at":"2024-12-04T17:10:29.407Z","updated_at":"2025-10-04T02:55:49.455Z","avatar_url":"https://github.com/WoLfulus.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flatt\n\nFlatbuffers ~code~ reflection based generation tool with scripting support.\n\n## Why?\n\nFlatbuffers is awesome, but you'll eventually need to (or wish you could) write additional code generation steps for your schema files. For example, generating a network protocol handler/dispatcher for you client and server and keep them in sync.\n\n## How does it work?\n\n`flatt` exposes a `lua` runtime with some additional helper functions to help you deal with Flatbuffers schema files, reflection and template rendering. You can for example write a `flatt` script that will reflect your schema, manipulate that data, and render (using a template engine or not) a file with the content you just processed.\n\nAll builtin lua libraries are exported and you can use `luarocks` packages with it if you want to.\n\n\u003e An example of what a flatt script looks like:\n\n```lua\n-- luarocks install lunajson\nlocal lunajson = require(\"lunajson\")\n\nflatt.log.info(\"Generating headers...\")\nflatt.flatc({ \"--cpp\", \"./schema.fbs\" })\n\nlocal json = flatt.reflect(\"./schema.fbs\")\nflatt.log.trace(json)\n\n--[[\n  {\n    \"tables\": [\n      {\n        \"id\": 182975129,\n        \"name\": \"MyTable\",\n        \"namespace\": \"my.namespace\",\n        \"fields\": [\n          {\n            \"name\": \"some_field\",\n            ...\n          }\n        ]\n      }\n      ...\n    ],\n    \"structs\": [\n      ...\n    ],\n    ...\n  }\n]]\n\nlocal info = lunajson.decode(json)\n\n-- generate a file using `info` data\n\n```\n\n## Usage\n\n### Installation\n\n- `npm install -g flatt`\n\n### Requirements\n\n- Windows (PRs welcome to add Linux+WSL and Mac support)\n\n### Overview\n\n\u003e `flatt some/project.lua`\n\n###\n\n## Building\n\n### Requirements\n\n- `scoop install cmake`\n- `scoop install charm-gum`\n- `scoop install just`\n\n### Compiling\n\n\u003e `npm install \u0026\u0026 npm run build`\n\n---\n\n# API\n\n## `vars`\n\n---\n\n### `flatt.vars.flatt_dir`\n\nHas the `flatt` executable directory.\n\n### `flatt.vars.project_dir`\n\nProject directory (from the given project script file).\n\n### `flatt.vars.argv`\n\nA table (list) of arguments passed next to the script file.\n\n```\n$ flatt project.lua --hello --world abc 123\n```\n\n```lua\nflatt.vars.argv\n-- { \"--hello\", \"--world\", \"abc\", \"123\" }\n\nflatt.vars.argv[1]\n-- { \"--hello\" }\n```\n\n```lua\n-- `luarocks install argparse`\nlocal argparse = require(\"argparse\")\n\nlocal parser = argparse(\"example\", \"Arguments example.\")\nparser:flag(\"-h --hello\", \"Hello argument.\", \"\")\nparser:flag(\"-w --world\", \"World argument.\", \"\")\nparser:argument(\"a\", \"Some value\")\nparser:argument(\"b\", \"Some value\")\n\nlocal args = parser:parse(flatt.vars.argv)\n\nargs.hello\n-- true\n\nargs.world\n-- false\n\nargs.a\n-- \"abc\"\n\nargs.b\n-- \"123\"\n```\n\n---\n\n## `flatc`\n\n---\n\n### `flatt.flatc(arguments)`\n\n```lua\nflatt.flatc({ \"--cpp\", \"schema.fbs\" })\n-- return: the exit code\n```\n\n---\n\n## `shell`\n\n---\n\n### `flatt.shell(command, arguments)`\n\n```lua\nflatt.shell(\"echo\", { \"hello\", \"world\" })\n-- return: the exit code\n```\n\n---\n\n## `reflect`\n\n---\n\n### `flatt.reflect(path)`\n\n```lua\nflatt.reflect(\"schema.fbs\")\n--[[\n  {\n    // JSON encoded schema\n  }\n]]\n```\n\n---\n\n## `log`\n\n---\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    Functions\n  \u003c/summary\u003e\n\n### `Level` list\n\n- `trace`\n- `debug`\n- `info`\n- `warn`\n- `error`\n- `critical`\n\n### `flatt.file.set_level(level)`\n\n```lua\nflatt.log.set_level(\"info\")\n-- Sets the current logging level\n```\n\n### `flatt.file.get_level()`\n\n```lua\nflatt.log.get_level()\n-- Gets the current logging level\n```\n\n### `flatt.file.trace(line)`\n\n```lua\nflatt.log.trace(\"log line\")\n-- Writes to console in white (windows)\n```\n\n### `flatt.file.trace(line)`\n\n```lua\nflatt.log.trace(\"log line\")\n-- Writes to console in white (windows)\n```\n\n### `flatt.file.debug(line)`\n\n```lua\nflatt.log.debug(\"log line\")\n-- Writes to console in blue (windows)\n```\n\n### `flatt.file.info(line)`\n\n```lua\nflatt.log.info(\"log line\")\n-- Writes to console in green (windows)\n```\n\n### `flatt.file.warn(line)`\n\n```lua\nflatt.log.warn(\"log line\")\n-- Writes to console in yellow (windows)\n```\n\n### `flatt.file.error(line)`\n\n```lua\nflatt.log.error(\"log line\")\n-- Writes to console in red (windows)\n```\n\n### `flatt.file.critical(line)`\n\n```lua\nflatt.log.critical(\"log line\")\n-- Writes to console in white with red background (windows)\n```\n\n\u003c/details\u003e\n\n---\n\n## `file`\n\n---\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    Functions\n  \u003c/summary\u003e\n\n### `flatt.file.write(path, data)`\n\n```lua\nflatt.dir.read(\"hello.txt\", \"Hello world!)\n-- return: \"Hello world!\"\n```\n\n### `flatt.file.read(path)`\n\n```lua\nflatt.dir.read(\"hello.txt\")\n-- return: \"Hello world!\"\n```\n\n### `flatt.file.exists(path)`\n\n```lua\nflatt.dir.exists(\"./non-existing-file.ext\")\n-- return: false\n\nflatt.dir.exists(\"hello.txt\")\n-- return: true\n```\n\n### `flatt.file.hash(path)`\n\n```lua\nflatt.dir.hash(\"./non-existing-file.ext\")\n-- return: nil\n\nflatt.dir.hash(\"some-file.ext\")\n-- return: \"EDCBA5DD333A60F3C98452672A1AB1711409040D\"\n```\n\n\u003c/details\u003e\n\n---\n\n## `dir`\n\n---\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    Functions\n  \u003c/summary\u003e\n\n### `flatt.dir.hash(path)`\n\n```lua\nflatt.dir.hash(\"./non-existing-dir\")\n-- return: nil\n\nflatt.dir.hash(\".\")\n-- return: \"4CF8ADEDB3B43E78645E4DE673D2D7DD4CFADA58\"\n```\n\n\u003c/details\u003e\n\n---\n\n## `templates`\n\n---\n\nBuiltin provided template engine functions (inja).\nUse `aspect` for a more Lua friendly template system.\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    Functions\n  \u003c/summary\u003e\n\n### `flatt.templates.render_string(template, data)`\n\n\u003e Accepts JSON encoded string for data.\n\n```lua\nflatt.templates.render_string(\"hello {{name}}\", \"{\\\"name\\\":\\\"world\\\"}\")\n-- return: \"hello world\"\n```\n\n### `flatt.templates.render_file(src, dest, data)`\n\n\u003e Accepts JSON encoded string for data.\n\n```lua\nflatt.templates.render_string(\"template.txt\", \"output.txt\", \"{\\\"name\\\":\\\"world\\\"}\")\n-- return: true\n```\n\n---\n\n## `string`\n\n---\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    Functions\n  \u003c/summary\u003e\n\n### `flatt.string.pad_left(string, len, pad = \" \")`\n\n```lua\nflatt.string.pad_left(\"1234\", 8)\n-- return: \"    1234\"\n\nflatt.string.pad_left(\"1234\", 8, \"0\")\n-- return: \"00001234\"\n```\n\n### `flatt.string.pad_right(string, len, pad = \" \")`\n\n```lua\nflatt.string.pad_left(\"1234\", 8)\n-- return: \"1234    \"\n\nflatt.string.pad_right(\"1234\", 8, \"0\")\n-- return: \"12340000\"\n```\n\n### `flatt.string.starts_with(string, string)`\n\n```lua\nflatt.string.starts_with(\"hello world\", \"hello\")\n-- return: true\n\nflatt.string.starts_with(\"hello world\", \"world\")\n-- return: false\n```\n\n### `flatt.string.ends_with(string, string)`\n\n```lua\nflatt.string.ends_with(\"hello world\", \"hello\")\n-- return: false\n\nflatt.string.ends_with(\"hello world\", \"world\")\n-- return: true\n```\n\n### `flatt.string.split(string, delim, limit = 0)`\n\n```lua\nflatt.string.split(\"hello world\", \" \")\n-- return: {\"hello\", \"world\"}\n\nflatt.string.split(\"is this real life\", \" \", 3)\n-- return: {\"is\", \"this\", \"real life\"}\n```\n\n### `flatt.string.trim(string)`\n\n```lua\nflatt.string.trim(\"  hello    world  \")\n-- return: \"hello    world\"\n```\n\n### `flatt.string.trim_left(string)`\n\n```lua\nflatt.string.trim(\"  hello    world  \")\n-- return: \"hello    world  \"\n```\n\n### `flatt.string.trim_right(string)`\n\n```lua\nflatt.string.trim(\"  hello    world\")\n-- return: \"hello    world  \"\n```\n\n### `flatt.string.explode(string)`\n\n\u003e Splits the string whenever one of the following characters is found: `. -_|/\\`\n\n```lua\nflatt.string.explode(\"a.b c-d|e/f\\\\g\")\n-- return: { \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\" }\n```\n\n### `flatt.string.join(strings, delim = \",\")`\n\n```lua\nflatt.string.join({ \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\" }, \"~\")\n-- return: \"a~b~c~d~e~f~g\"\n```\n\n### `flatt.string.lower_case(string)`\n\n```lua\nflatt.string.lower_case(\"NewGUIAlertBox\")\n-- return: \"newguialertbox\"\n```\n\n### `flatt.string.upper_case(string)`\n\n```lua\nflatt.string.upper_case(\"NewGUIAlertBox\")\n-- return: \"NEWGUIALERTBOX\"\n```\n\n### `flatt.string.ucfirst(string)`\n\n```lua\nflatt.string.ucfirst(\"NewGUIAlertBox\")\n-- return: \"NewGUIAlertBox\"\n```\n\n### `flatt.string.lcfirst(string)`\n\n```lua\nflatt.string.lcfirst(\"NewGUIAlertBox\")\n-- return: \"newGUIAlertBox\"\n```\n\n### `flatt.string.snake_case(string)`\n\n```lua\nflatt.string.snake_case(\"NewGUIAlertBox\")\n-- return: \"new_gui_alert_box\"\n```\n\n### `flatt.string.kebab_case(string)`\n\n```lua\nflatt.string.kebab_case(\"NewGUIAlertBox\")\n-- return: \"new-gui-alert-box\"\n```\n\n### `flatt.string.pascal_case(string)`\n\n```lua\nflatt.string.pascal_case(\"NewGUIAlertBox\")\n-- return: \"NewGuiAlertBox\"\n```\n\n### `flatt.string.camel_case(string)`\n\n```lua\nflatt.string.camel_case(\"NewGUIAlertBox\")\n-- return: \"newGuiAlertBox\"\n```\n\n### `flatt.string.const_case(string)`\n\n```lua\nflatt.string.const_case(\"NewGUIAlertBox\")\n-- return: \"NEW_GUI_ALERT_BOX\"\n```\n\n### `flatt.string.train_case(string)`\n\n```lua\nflatt.string.train_case(\"NewGUIAlertBox\")\n-- return: \"New-Gui-Alert-Box\"\n```\n\n### `flatt.string.ada_case(string)`\n\n```lua\nflatt.string.ada_case(\"NewGUIAlertBox\")\n-- return: \"New_Gui_Alert_Box\"\n```\n\n### `flatt.string.cobol_case(string)`\n\n```lua\nflatt.string.cobol_case(\"NewGUIAlertBox\")\n-- return: \"NEW-GUI-ALERT-BOX\"\n```\n\n### `flatt.string.dot_case(string)`\n\n```lua\nflatt.string.dot_case(\"NewGUIAlertBox\")\n-- return: \"new.gui.alert.box\"\n```\n\n### `flatt.string.path_case(string)`\n\n```lua\nflatt.string.path_case(\"NewGUIAlertBox\")\n-- return: \"new/gui/alert/box\"\n```\n\n### `flatt.string.space_case(string)`\n\n```lua\nflatt.string.space_case(\"NewGUIAlertBox\")\n-- return: \"new gui alert box\"\n```\n\n### `flatt.string.capital_case(string)`\n\n```lua\nflatt.string.capital_case(\"NewGUIAlertBox\")\n-- return: \"New Gui Alert Box\"\n```\n\n### `flatt.string.cpp_case(string)`\n\n```lua\nflatt.string.cpp_case(\"NewGUIAlertBox\")\n-- return: \"new::gui::alert::box\"\n```\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwolfulus%2Fflatt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwolfulus%2Fflatt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwolfulus%2Fflatt/lists"}