aboutsummaryrefslogtreecommitdiff
path: root/src/extensions/string.lua
blob: 247d31a3244e36e4738426a32e5742fe2395a9ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function string:flag_name()
	if self:sub(1, 2) ~= "--" then
		return nil
	end

	return self:sub(3)
end

function string:split(sep)
	splits = {}

	for split in self:gmatch("[^" .. sep .. "]+") do
		splits[#splits + 1] = split
	end

	return splits
end

return {
	tests = {
		function()
			local path = 'some/path/here'
			assert.equals({ 'some', 'path', 'here' }, path.split("/"))
		end,
	}
}