-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcatalyst
More file actions
executable file
·103 lines (81 loc) · 2.85 KB
/
Copy pathcatalyst
File metadata and controls
executable file
·103 lines (81 loc) · 2.85 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/lua
-- The following is a cursed alternative to the current shebang, but it
-- (probably) guarantees the correct path
-- #!/usr/bin/env -S sh -c 'RP="$(realpath "$0")"; cd "$(dirname "$RP")"; exec /bin/lua "$RP"'
--
local options = require("lua.option")
-- Exit early if bad script params (show usage blob)
local _, options_err = options:GetError()
if not options_err then
_, options_err = options:Verify()
end
if options_err then
print(options_err)
options:Usage()
return
end
-- Exit early if bad script env
local env = require("lua.env") -- Will assert in the main chunk!
-- Exit early if bad config spec
-- TODO: Do we want to check all spec files or just selected ones?
-- local features = require("lua.feature")
-- if features.error() then
-- print(features.error())
-- return
-- end
--
-- Script env good to go!
print("└── >>> CATALYST CONFIG HELPER\n")
-- print("───────────────────────────────────")
options:Dump()
-- Check for additional early-exit conditions
if options.mode == "USAGE" then
print("───────────────────────────────────")
options:Usage()
return
elseif options.mode == "TEST" then
print("───────────────────────────────────")
require("lua.test")
return
end
local manager = require("lua.manager")
-- Current use case means that any other option will at least build a feature
-- list and check the setup of those features
manager:ProcessSystem(options.system) -- NOTE: Specify only common features by setting the target system to NONE
manager:ModifySelected(options.features) -- Perform the initial list modification (per script argument)
if options.script then
manager:PrintSelected()
print() -- Formatting
else
-- Prompt user for modifications
manager:InteractiveSelect()
end
--
-- CORE "ACTUALLY DOES THE THING" LOOP
print("reminder to myself that the main file is truncated!!")
do return end
local did_something = false -- Just for friendly output
for feat, spec in pairs(features) do
print("── INSTALLING", feat)
local feature_dir = repo_dir .. "/" .. feat
-- Copy/link common files (copy is TODO)
local common_files = spec.location
if type(common_files) == "string" then
common_files = { ["."] = common_files }
end
if type(common_files) == "table" then
for file, install_location in pairs(common_files) do
local link_target = feature_dir .. "/common/" .. file
-- While this would be a valid path, it means that a string was
-- empty when it should not have been
assert(not link_target:match("//"))
local cmd = string.format("ln -s %s %s", link_target, install_location)
print(cmd)
end
end
did_something = true
end
if not did_something then
print("No features were selected :(")
return
end