Skip to content

Instantly share code, notes, and snippets.

@lolbinarycat
Created June 17, 2025 17:28
Show Gist options
  • Save lolbinarycat/04e2146cd3b6808b3bdf057fd0648b63 to your computer and use it in GitHub Desktop.
Save lolbinarycat/04e2146cd3b6808b3bdf057fd0648b63 to your computer and use it in GitHub Desktop.
script for toml reformatting
-- 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