-- lx format
local format = require("core.format")

-- SHA-256 is always 64 hexadecimal digits
local digest_pattern = string.rep("%x", 64)

format.register({
	name = "SHA-256 Checksums",
	shortname = "SHA-256",
	author = "liqube",

	extensions = {
		"sha256",
	},
	filenames = {
		"SHA256SUMS",
		"SHA256SUMS.txt",
	},

	-- First complete checksum record
	headers = "^" .. digest_pattern .. " [ *][^\r\n]+",

	patterns = {
		-- Optional manifest comments
		{ pattern = "#.-\n", type = "comment", line_start = true },

		-- Exact digest, separator/mode, filename
		{
			pattern = "(" .. digest_pattern .. ")( [ %*])([^\r\n]+)",
			type = { "hex", "operator", "normal" },
			line_start = true,
		},
	},
})
