blob: 4ad20515b3a66d710569b4e09ad4663a42b4b0bd (
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
manager = {}
manager.base_path = Path:new(os.getenv('HOME')) / '.local/share/blueprint'
manager.install_path = manager.base_path / 'templates'
manager.base_path:make_directory { create_parents = true }
manager.install_path:make_directory { create_parents = true }
function manager.list()
return manager.install_path:entries()
end
function manager.install(path, name)
if not (path / 'build.lua'):exists() then
error('build.lua does not exist.')
end
local target = (manager.install_path / (name or path:name()))
if target:exists() then
error('template already installed.')
end
path:copy_to(target)
end
function manager.remove(name)
if name == nil or not (manager.install_path / name):exists() then
error('template does not exist.')
end
(manager.install_path / name):remove { recursive = true, force = true }
end
function manager.get(name)
if (manager.install_path / name):exists() then
return manager.install_path / name / 'build.lua'
end
return nil
end
|