Created
June 17, 2025 17:28
-
-
Save lolbinarycat/04e2146cd3b6808b3bdf057fd0648b63 to your computer and use it in GitHub Desktop.
script for toml reformatting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- script for removing the sections of toml files | |
| -- and instead fully specifying each key. | |
| -- | |
| -- in particular this is used for the migration of | |
| -- rust-lang/rust bootstrap.example.toml | |
| section = "" | |
| for ln in io.input():lines() do | |
| local m = string.match(ln, "^%[([a-zA-Z0-9_.-]+)%]") | |
| if m then | |
| if string.match(m, "target.") then | |
| -- the target-specific section is not modified | |
| print(ln) | |
| section = "" | |
| else | |
| section = m .. "." | |
| end | |
| elseif string.match(ln, "^#?[a-zA-Z0-9_-]+ +=") then | |
| local h = string.match(ln, "^#") | |
| local s = string.gsub(ln, "^#", "") | |
| print(h..section..s) | |
| else | |
| print(ln) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment