-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
296 lines (232 loc) · 11.7 KB
/
install.py
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
### DOTS INTERACTIVE INSTALLER ###
"""
The DOTS Interactive installer clones my dotfiles repository from Github and
symlinks each subdirectory to its respective target directory.
It may also install and configure required or frequently used programs and
packages from APT or external (verified) sources; however, users may opt out of
these additional installations and configurations at their own discretion.
"""
import os
import sys
import argparse
class Page:
def __init__(self, name, char, opts):
self.name = name
self.char = char
self.pick = 0
self.opts = {}
if len(opts) > 0:
for i in range(len(opts)):
self.opts.update(chr(i + 97), opts[i])
self.size = len(self.opts)
def print(self):
#1234567890123456789012345678901234567890123456789012345678901234#
print(" ")
print("# {" + self.char + "} " + self.name + ": " + self.pick +
" out of " + self.size + " specified ")
print(" ")
print(" ( ) [c] git ")
for item in self..items():
print(" (" + "V" + ") [" + item[0] + "] " + item[1])
print(" ")
print(" Actions ")
print(" ")
print(" [+] Select All Options ")
print(" [-] Remove All Options ")
print(" [R] Return to Main Menu ")
print(" ")
def exec(self):
while True:
self.print()
input_char = input(" Enter Action: ")
match input_char:
case '+':
continue
case '-':
continue
case 'r' | 'R': break
case _:
print("Unacceptable Input; Please Retry")
continue
def col_func(val, lim):
while True:
#1234567890123456789012345678901234567890123456789012345678901234#
print(" ")
print("# {C} Collections: x out of y specified ")
print(" ")
print(" ( ) [a] fish ")
print(" ( ) [b] nvim ")
print(" ( ) [c] git ")
print(" ")
print(" Actions ")
print(" ")
print(" [+] Select All Options ")
print(" [-] Remove All Options ")
print(" [R] Return to Main Menu ")
print(" ")
input_char = input(" Enter Action: ")
match input_char:
case '+':
val = lim
continue
case '-':
val = 0
continue
case 'r' | 'R': return val
case _:
print("Unacceptable Input; Please Retry")
continue
def pac_func(val, lim):
while True:
#1234567890123456789012345678901234567890123456789012345678901234#
print(" ")
print("# {P} Packages: x out of y specified ")
print(" ")
print(" ( ) [a] fish ")
print(" ( ) [b] nvim ")
print(" ( ) [c] git ")
print(" ")
print(" Actions ")
print(" ")
print(" [+] Select All Options ")
print(" [-] Remove All Options ")
print(" [R] Return to Main Menu ")
print(" ")
input_char = input(" Enter Action: ")
match input_char:
case '+':
val = lim
continue
case '-':
val = 0
continue
case 'r' | 'R': return val
case _:
print("Unacceptable Input; Please Retry")
continue
def dir_func(val, lim):
while True:
#1234567890123456789012345678901234567890123456789012345678901234#
print(" ")
print("# {D} Directories ")
print(" ")
print(" [H] $HOME: ")
print(" LINKS: x out of y specified ")
print(" [a] fish: ")
print(" [b] nvim: ")
print(" [c] git : ")
print(" ")
print(" Actions ")
print(" ")
print(" [+] Select All Options ")
print(" [-] Remove All Options ")
print(" [R] Return to Main Menu ")
print(" ")
input_char = input(" Enter Action: ")
match input_char:
case '+':
val = lim
continue
case '-':
val = 0
continue
case 'r' | 'R': return val
case _:
print("Unacceptable Input; Please Retry")
continue
def opt_func(val, lim):
while True:
#1234567890123456789012345678901234567890123456789012345678901234#
print(" ")
print("# {O} Options ")
print(" ")
print(" ( ) [1] Set FISH as Default Shell ")
print(" ( ) [2] Use SYMLINKS instead of Hard Copying ")
print(" ")
print(" Actions ")
print(" ")
print(" [+] Select All Options ")
print(" [-] Remove All Options ")
print(" [R] Return to Main Menu ")
print(" ")
input_char = input(" Enter Action: ")
match input_char:
case '+':
val = lim
continue
case '-':
val = 0
continue
case 'r' | 'R': return val
case _:
print("Unacceptable Input; Please Retry")
continue
if __name__ == "__main__": # MAIN Function
# CHECK if Python is above 3.10 => Necessary for `match-case`
assert sys.version_info >= (3, 10)
# Parse Arguments
p = argparse.ArgumentParser(description = "DOTS Interactive Installer",
formatter_class = argparse.ArgumentDefaultsHelpFormatter)
p.add_argument("-p", "--profile", help = "Installer Profile")
args = p.parse_args()
col_set = 0 # Binary Integer for Collections
pac_set = 0 # Binary Integer for Packages
dir_set = 0 # Binary Integer for Directories
opt_set = 0 # Binary Integer for Options
# if args[0] != "": # Profile Location is given => Process profile
# Supported Collections: FISH | GIT | NVIM | TEX
# Supported Pacakges:
# FISH: fish, omf
# GIT : git, gh
# NVIM: nvim
# TEX : (tex installation from internet)
while True: # Start with Printing Main Page
#1234567890123456789012345678901234567890123456789012345678901234#
print(" ")
print("### DOTS INTERACTIVE INSTALLER ###")
print(" ")
print(" This is the DOTS Interactive Installer, a tool for ")
print(" interactively installing and configuring my dotfiles. ")
print(" ")
print(" [C] Collections: x out of y specified ") # Collections
print(" ")
print(" ")
print(" [P] Packages: x out of y specified ") # Packages
print(" ")
print(" ")
print(" [D] Directories ") # Directories
print(" ")
print(" $HOME: ") # $HOME
print(" LINKS: x out of y specified ") # `x/n symlinks specified`
print(" ")
print(" [O] Options ") # Options
print(" ")
print(" ( ) Set FISH as Default Shell ")
print(" ( ) Use SYMLINKS instead of Hard Copying ")
print(" ")
print(" Actions ") # Interactions
print(" ")
print(" [I] Install DOTS ") # INSTALL
print(" [S] Save Current Settings to $HOME and Exit ") # SAVE
print(" [Q] Quit Installer ") # QUIT
print(" ")
input_char = input(" Enter Action: ")
# receive input_char
return_val = 0
match input_char:
case 'c' | 'C': col_set = col_func(col_set, 2 ** 3 - 1) # Collections
case 'p' | 'P': pac_set = pac_func(pac_set, 2 ** 3 - 1) # Packages
case 'd' | 'D': dir_set = dir_func(dir_set, 2 ** 3 - 1) # Directories
case 'o' | 'O': opt_set = opt_func(opt_set, 2 ** 3 - 1) # Options
case 'i' | 'I': # Begin Installation
# Commence System-Level Installation
break
case 's' | 'S': # Save Current Installer Profile to HOME DIR
# Save with JSON file
break
case 'q' | 'Q': # Exit
break
case _: # Unrecognisable => continue
continue
if return_val: break
else: continue