-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplan.lua
More file actions
36 lines (32 loc) · 748 Bytes
/
plan.lua
File metadata and controls
36 lines (32 loc) · 748 Bytes
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
27
28
29
30
31
32
33
34
35
36
---@class Plan
---@field actions Action[]
---@field enable_ansi boolean
Plan = {}
Plan.__index = Plan
Plan.__name = "Plan"
---@param enable_ansi boolean?
---@return Plan
function Plan:new(enable_ansi)
enable_ansi = enable_ansi == nil and true or enable_ansi
self = {}
setmetatable(self, Plan)
---@cast self Plan
self.actions = {}
self.enable_ansi = not not enable_ansi
return self
end
---@param action Action?
---@return Plan
function Plan:add(action)
table.insert(self.actions, action)
return self
end
---@return string
function Plan:__tostring()
local text = "action lines chars path"
for _, action in ipairs(self.actions) do
text = text .. "\n" .. action:tostring(self.enable_ansi)
end
return text
end
return Plan