-
Notifications
You must be signed in to change notification settings - Fork 1
/
occultist.sh
executable file
·780 lines (686 loc) · 54.2 KB
/
occultist.sh
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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
#!/bin/bash
# The spell definition file
JSON_FILE='occultist.json'
LOCK_FILE='occultist-lock.json'
TRACKER_FILE='.occultist-tracker.json'
TMP_FILE='.tmp.json'
HOST='https://occultist.io'
API_BASE="$HOST/api"
PROGRAM='Occultist'
PROGRAM_BINARY='occultist'
PROGRAM_PATH=$(which occultist)
PROGRAM_RAW_URL='https://raw.githubusercontent.com/chaos-lang/occultist/master/occultist.sh'
LANGUAGE_NAME='the Chaos language'
LANGUAGE_NAME_SHORT='Chaos'
LANGUAGE_BINARY='chaos'
LANGUAGE_PATH=$(which chaos)
LANGUAGE_REPO='https://github.com/chaos-lang/chaos.git'
DESCRIPTION="Dependency manager for $LANGUAGE_NAME"
SPELLS_DIR_NAME='spells'
THIS_DIR=$(pwd)
DEPENDENCY_ROOT=$THIS_DIR
COPYRIGHT_NOTICE='Copyright (C) 2019-2021 Chaos Language Development Authority <info@chaos-lang.org>'
LICENSE='GNU General Public License v3.0'
LICENSE_URL='https://raw.githubusercontent.com/chaos-lang/occultist/master/LICENSE'
# Terminal colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
BOLD_RED='\033[1;31m'
BOLD_YELLOW='\033[1;33m'
BOLD_PURPLE='\033[1;35m'
BOLD_NC='\033[1m'
UNDERLINED_NC='\033[4m'
uname_out="$(uname -s)"
case "${uname_out}" in
Linux*) PLATFORM=Linux;;
Darwin*) PLATFORM=Mac;;
CYGWIN*) PLATFORM=Cygwin;;
MINGW*) PLATFORM=MinGw;;
*) PLATFORM="UNKNOWN:${uname_out}"
esac
if [ ! "$PLATFORM" = "MinGw" ]; then
SUDO='sudo '
else
SUDO=''
fi
if [ "$#" -lt 1 ] || [ $1 = "-l" ] || [ $1 = "--license" ]; then
wget -q -O- $LICENSE_URL | less
exit 0
fi
printf "${YELLOW}%s${NC} - %s - ${YELLOW}%s${NC}\n" "$PROGRAM" "$DESCRIPTION" "$HOST"
# Program icon ANSI colors
cat << "EOF"
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;234m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;232m.[39m[38;5;232m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;237m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;233m.[39m[38;5;235m,[39m[38;5;237m:[39m[38;5;239m;[39m[38;5;240mi[39m[38;5;240mi[39m[38;5;239m;[39m[38;5;237m:[39m[38;5;235m,[39m[38;5;233m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;232m [39m[38;5;233m.[39m[38;5;235m,[39m[38;5;237m:[39m[38;5;239mi[39m[38;5;241mi[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;241mi[39m[38;5;239mi[39m[38;5;237m:[39m[38;5;235m,[39m[38;5;233m.[39m[38;5;232m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;235m,[39m[38;5;238m;[39m[38;5;240mi[39m[38;5;241m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;241m1[39m[38;5;240mi[39m[38;5;238m;[39m[38;5;235m,[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;234m.[39m[38;5;241m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;241m1[39m[38;5;234m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;232m.[39m[38;5;239mi[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;241m1[39m[38;5;102m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;239mi[39m[38;5;232m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;238m;[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;102m1[39m[38;5;240mi[39m[38;5;59m;[39m[38;5;59m:[39m[38;5;235m,[39m[38;5;59m,[39m[38;5;59m,[39m[38;5;235m,[39m[38;5;59m:[39m[38;5;59m;[39m[38;5;240mi[39m[38;5;241m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;238m;[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;235m,[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;102mi[39m[38;5;239mi[39m[38;5;237m:[39m[38;5;59m,[39m[38;5;59m,[39m[38;5;59m,[39m[38;5;59m:[39m[38;5;102mi[39m[38;5;144mt[39m[38;5;181mL[39m[38;5;181mL[39m[38;5;144mt[39m[38;5;102mi[39m[38;5;59m:[39m[38;5;59m,[39m[38;5;59m,[39m[38;5;236m,[39m[38;5;59m:[39m[38;5;102m;[39m[38;5;241mi[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;235m,[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;233m.[39m[38;5;241mi[39m[38;5;241m1[39m[38;5;238m;[39m[38;5;236m:[39m[38;5;234m,[39m[38;5;58m.[39m[38;5;59m:[39m[38;5;59m:[39m[38;5;101mi[39m[38;5;144mt[39m[38;5;181mL[39m[38;5;187mC[39m[38;5;187mG[39m[38;5;187mG[39m[38;5;187mC[39m[38;5;187mC[39m[38;5;187mG[39m[38;5;187mG[39m[38;5;187mC[39m[38;5;181mL[39m[38;5;144mf[39m[38;5;101mi[39m[38;5;59m;[39m[38;5;59m:[39m[38;5;58m.[39m[38;5;234m,[39m[38;5;236m:[39m[38;5;238m;[39m[38;5;241m1[39m[38;5;241mi[39m[38;5;233m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;232m [39m[38;5;239m;[39m[38;5;242m1[39m[38;5;241mi[39m[38;5;236m:[39m[38;5;235m,[39m[38;5;16m [39m[38;5;59m;[39m[38;5;187mC[39m[38;5;138mt[39m[38;5;59m:[39m[38;5;59m:[39m[38;5;59m;[39m[38;5;59m:[39m[38;5;59m:[39m[38;5;59m:[39m[38;5;59m;[39m[38;5;59m;[39m[38;5;59m:[39m[38;5;59m:[39m[38;5;59m:[39m[38;5;59m;[39m[38;5;59m:[39m[38;5;59m:[39m[38;5;138mt[39m[38;5;187mC[39m[38;5;59m;[39m[38;5;16m [39m[38;5;235m,[39m[38;5;236m:[39m[38;5;241mi[39m[38;5;242m1[39m[38;5;239m;[39m[38;5;232m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;237m:[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;239m;[39m[38;5;16m [39m[38;5;101m;[39m[38;5;187mG[39m[38;5;187mG[39m[38;5;187mC[39m[38;5;181mC[39m[38;5;181mL[39m[38;5;187mC[39m[38;5;187mG[39m[38;5;187mG[39m[38;5;224mG[39m[38;5;224mG[39m[38;5;187mG[39m[38;5;187mG[39m[38;5;187mC[39m[38;5;181mL[39m[38;5;187mC[39m[38;5;187mC[39m[38;5;187mG[39m[38;5;187mG[39m[38;5;101m;[39m[38;5;16m [39m[38;5;239m;[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;237m:[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;235m,[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;239m;[39m[38;5;16m [39m[38;5;101mi[39m[38;5;230m0[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;224m0[39m[38;5;101m;[39m[38;5;101m;[39m[38;5;224m0[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m0[39m[38;5;101mi[39m[38;5;16m [39m[38;5;239m;[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;235m,[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;233m.[39m[38;5;238m;[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;241mi[39m[38;5;234m,[39m[38;5;16m.[39m[38;5;144mt[39m[38;5;224m0[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;224m0[39m[38;5;138m1[39m[38;5;138m1[39m[38;5;224m0[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;224m0[39m[38;5;144mt[39m[38;5;16m.[39m[38;5;234m,[39m[38;5;241mi[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;238m;[39m[38;5;233m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;235m,[39m[38;5;239m;[39m[38;5;241m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;241m1[39m[38;5;59m:[39m[38;5;16m.[39m[38;5;95m;[39m[38;5;187mC[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;145mf[39m[38;5;138m1[39m[38;5;138m1[39m[38;5;138mt[39m[38;5;138mt[39m[38;5;138mt[39m[38;5;102mi[39m[38;5;102m1[39m[38;5;224m0[39m[38;5;230m8[39m[38;5;187mC[39m[38;5;95m;[39m[38;5;16m.[39m[38;5;237m:[39m[38;5;241m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;241m1[39m[38;5;239m;[39m[38;5;235m,[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;232m [39m[38;5;236m,[39m[38;5;239mi[39m[38;5;240mi[39m[38;5;241m1[39m[38;5;242m1[39m[38;5;239mi[39m[38;5;23m.[39m[38;5;59m,[39m[38;5;144mf[39m[38;5;224m0[39m[38;5;145mf[39m[38;5;138m1[39m[38;5;138m1[39m[38;5;138m1[39m[38;5;138m1[39m[38;5;138m1[39m[38;5;138mt[39m[38;5;145mf[39m[38;5;224m0[39m[38;5;144mf[39m[38;5;59m,[39m[38;5;17m.[39m[38;5;239mi[39m[38;5;242m1[39m[38;5;241m1[39m[38;5;240mi[39m[38;5;239mi[39m[38;5;236m,[39m[38;5;232m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;232m.[39m[38;5;234m.[39m[38;5;235m,[39m[38;5;236m:[39m[38;5;238m;[39m[38;5;239m;[39m[38;5;59m,[39m[38;5;16m.[39m[38;5;101mi[39m[38;5;187mG[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;230m8[39m[38;5;187mG[39m[38;5;101mi[39m[38;5;16m.[39m[38;5;235m,[39m[38;5;239m;[39m[38;5;238m;[39m[38;5;236m:[39m[38;5;235m,[39m[38;5;234m.[39m[38;5;232m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;232m.[39m[38;5;233m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;59m,[39m[38;5;144mf[39m[38;5;187mC[39m[38;5;187mC[39m[38;5;187mC[39m[38;5;187mC[39m[38;5;144mf[39m[38;5;59m,[39m[38;5;16m [39m[38;5;232m [39m[38;5;233m.[39m[38;5;232m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;233m.[39m[38;5;235m,[39m[38;5;236m:[39m[38;5;237m:[39m[38;5;238m;[39m[38;5;238m;[39m[38;5;238m;[39m[38;5;238m;[39m[38;5;238m;[39m[38;5;237m;[39m[38;5;236m:[39m[38;5;234m,[39m[38;5;59m,[39m[38;5;16m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m.[39m[38;5;59m,[39m[38;5;234m,[39m[38;5;236m:[39m[38;5;238m;[39m[38;5;238m;[39m[38;5;238m;[39m[38;5;238m;[39m[38;5;238m;[39m[38;5;238m;[39m[38;5;237m:[39m[38;5;236m:[39m[38;5;235m,[39m[38;5;233m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;233m.[39m[38;5;237m:[39m[38;5;239mi[39m[38;5;241m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;241m1[39m[38;5;241mi[39m[38;5;240mi[39m[38;5;234m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m.[39m[38;5;240mi[39m[38;5;241mi[39m[38;5;241m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;241m1[39m[38;5;239mi[39m[38;5;237m:[39m[38;5;233m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;233m.[39m[38;5;238m;[39m[38;5;241m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;237m:[39m[38;5;16m [39m[38;5;100m;[39m[38;5;100m;[39m[38;5;16m [39m[38;5;237m:[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;241m1[39m[38;5;238m;[39m[38;5;233m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;235m,[39m[38;5;102mi[39m[38;5;102mi[39m[38;5;102m;[39m[38;5;59m;[39m[38;5;59m;[39m[38;5;66m;[39m[38;5;102mi[39m[38;5;102m1[39m[38;5;102m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;240mi[39m[38;5;16m [39m[38;5;58m,[39m[38;5;215mf[39m[38;5;215mf[39m[38;5;58m,[39m[38;5;16m [39m[38;5;240mi[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;102m1[39m[38;5;102mi[39m[38;5;66m;[39m[38;5;59m;[39m[38;5;59m;[39m[38;5;102m;[39m[38;5;102mi[39m[38;5;102mi[39m[38;5;235m,[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m.[39m[38;5;59m,[39m[38;5;59m,[39m[38;5;58m,[39m[38;5;58m:[39m[38;5;94m;[39m[38;5;100m;[39m[38;5;94m:[39m[38;5;58m,[39m[38;5;58m,[39m[38;5;59m,[39m[38;5;59m,[39m[38;5;59m:[39m[38;5;59m;[39m[38;5;102mi[39m[38;5;102mi[39m[38;5;241m1[39m[38;5;241m1[39m[38;5;59m,[39m[38;5;16m.[39m[38;5;179mt[39m[38;5;221mL[39m[38;5;221mL[39m[38;5;179mt[39m[38;5;16m.[39m[38;5;59m,[39m[38;5;241m1[39m[38;5;102m1[39m[38;5;102mi[39m[38;5;102mi[39m[38;5;59m;[39m[38;5;59m:[39m[38;5;59m,[39m[38;5;59m,[39m[38;5;58m,[39m[38;5;58m,[39m[38;5;94m:[39m[38;5;100m;[39m[38;5;94m;[39m[38;5;58m:[39m[38;5;58m,[39m[38;5;59m,[39m[38;5;59m,[39m[38;5;16m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;58m,[39m[38;5;94m:[39m[38;5;100m;[39m[38;5;136mi[39m[38;5;137mi[39m[38;5;137mi[39m[38;5;136mi[39m[38;5;100m;[39m[38;5;100m;[39m[38;5;136mi[39m[38;5;137mi[39m[38;5;137mi[39m[38;5;137mi[39m[38;5;136mi[39m[38;5;100m;[39m[38;5;94m:[39m[38;5;58m,[39m[38;5;58m,[39m[38;5;59m,[39m[38;5;59m.[39m[38;5;16m [39m[38;5;100m;[39m[38;5;221mL[39m[38;5;221mL[39m[38;5;221mL[39m[38;5;221mL[39m[38;5;100m;[39m[38;5;16m [39m[38;5;59m.[39m[38;5;59m,[39m[38;5;58m,[39m[38;5;58m,[39m[38;5;94m:[39m[38;5;100m;[39m[38;5;136mi[39m[38;5;137mi[39m[38;5;137mi[39m[38;5;137mi[39m[38;5;136mi[39m[38;5;100m;[39m[38;5;100m;[39m[38;5;136mi[39m[38;5;137mi[39m[38;5;137mi[39m[38;5;136mi[39m[38;5;100m;[39m[38;5;94m:[39m[38;5;58m,[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;58m.[39m[38;5;94m:[39m[38;5;58m,[39m[38;5;58m,[39m[38;5;58m.[39m[38;5;16m.[39m[38;5;16m [39m[38;5;232m.[39m[38;5;59m:[39m[38;5;59m:[39m[38;5;59m,[39m[38;5;59m,[39m[38;5;59m,[39m[38;5;58m,[39m[38;5;58m,[39m[38;5;58m:[39m[38;5;94m:[39m[38;5;100m;[39m[38;5;100m;[39m[38;5;94m:[39m[38;5;16m [39m[38;5;58m,[39m[38;5;215mf[39m[38;5;221mL[39m[38;5;221mL[39m[38;5;221mL[39m[38;5;221mL[39m[38;5;215mf[39m[38;5;58m,[39m[38;5;16m [39m[38;5;94m:[39m[38;5;100m;[39m[38;5;100m;[39m[38;5;94m:[39m[38;5;58m:[39m[38;5;58m,[39m[38;5;58m,[39m[38;5;58m,[39m[38;5;59m,[39m[38;5;59m,[39m[38;5;59m:[39m[38;5;59m:[39m[38;5;232m.[39m[38;5;16m [39m[38;5;16m.[39m[38;5;58m.[39m[38;5;58m,[39m[38;5;58m,[39m[38;5;94m:[39m[38;5;58m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;232m [39m[38;5;238m;[39m[38;5;241m1[39m[38;5;241m1[39m[38;5;102m1[39m[38;5;241mi[39m[38;5;102mi[39m[38;5;102mi[39m[38;5;102m;[39m[38;5;59m;[39m[38;5;59m:[39m[38;5;16m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;52m.[39m[38;5;179mt[39m[38;5;221mL[39m[38;5;221mL[39m[38;5;221mL[39m[38;5;221mL[39m[38;5;221mL[39m[38;5;221mL[39m[38;5;179mt[39m[38;5;52m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m.[39m[38;5;59m:[39m[38;5;59m;[39m[38;5;102m;[39m[38;5;102mi[39m[38;5;102mi[39m[38;5;241mi[39m[38;5;241m1[39m[38;5;241m1[39m[38;5;241mi[39m[38;5;238m;[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;237m;[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;241m1[39m[38;5;241m1[39m[38;5;241mi[39m[38;5;240mi[39m[38;5;238m;[39m[38;5;234m,[39m[38;5;16m.[39m[38;5;94m:[39m[38;5;179mt[39m[38;5;215mL[39m[38;5;221mL[39m[38;5;221mL[39m[38;5;215mL[39m[38;5;179mt[39m[38;5;94m:[39m[38;5;16m.[39m[38;5;234m,[39m[38;5;238m;[39m[38;5;240mi[39m[38;5;241m1[39m[38;5;241m1[39m[38;5;241m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;237m:[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;236m:[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;241m1[39m[38;5;102m;[39m[38;5;59m,[39m[38;5;16m.[39m[38;5;94m:[39m[38;5;137m1[39m[38;5;137m1[39m[38;5;94m:[39m[38;5;16m.[39m[38;5;59m,[39m[38;5;102m;[39m[38;5;241m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;236m:[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;234m,[39m[38;5;241mi[39m[38;5;242m1[39m[38;5;242mi[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242mi[39m[38;5;102m;[39m[38;5;59m,[39m[38;5;16m.[39m[38;5;16m.[39m[38;5;59m,[39m[38;5;102m;[39m[38;5;242mi[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242m1[39m[38;5;242mi[39m[38;5;242m1[39m[38;5;241mi[39m[38;5;234m,[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;237m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;243m.[39m[38;5;242m.[39m[38;5;59m [39m[38;5;59m [39m[38;5;242m.[39m[38;5;243m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;242m.[39m[38;5;237m.[39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m[38;5;16m [39m
EOF
echo -e "${BOLD_PURPLE}${COPYRIGHT_NOTICE}${NC}"
echo -e "License: ${BOLD_PURPLE}${LICENSE}${NC}\n"
spinner() {
i=1
sp="/-\|"
echo -n ' '
while true
do
printf "\b${sp:i++%${#sp}:1}"
sleep .05
done
}
mingw_is_admin() {
net session > /dev/null 2>&1
if [ $? -eq 0 ]; then echo "admin"
else echo "user"; fi
}
get_latest_tag_or_default_branch() {
local BRANCH
BRANCH=$(git ls-remote --tags --refs ${1} | tail -n1 | sed 's/.*\///')
if [ -z $BRANCH ]; then
git init &> /dev/null
BRANCH=$(git remote show ${1} | grep "HEAD branch" | cut -d ":" -f 2)
BRANCH="${BRANCH:1}"
fi
echo $BRANCH
}
make_c() {
if [ ! "$PLATFORM" = "MinGw" ]; then
make $1 && return 0 || return 1
else
./make.bat $1 && return 0 || return 1
fi
}
install_language() {
if [ ! "$PLATFORM" = "MinGw" ]; then
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}To install ${LANGUAGE_NAME} you need to run this command as root!${NC}"
exit 10
fi
else
if [ ! "$(mingw_is_admin)" = "admin" ]; then
echo -e "${RED}To install ${LANGUAGE_NAME} you need to run as administrator!${NC}"
exit 10
fi
fi
if [ -z $1 ]; then
printf "Installing ${BOLD_PURPLE}${LANGUAGE_NAME}${NC} to the system\n"
else
VERSION=$1
VERSION_ORIG=$VERSION
if [[ $VERSION =~ ^[0-9x]+(\.[0-9x]+){0,3}$ ]] || [[ $VERSION =~ ^[0-9x]+(\.[0-9x]+){0,3}-.*$ ]] || [[ $VERSION =~ ^[0-9x]+(\.[0-9x]+){0,3}\+.*$ ]] || [[ $VERSION =~ ^[0-9x]+(\.[0-9x]+){0,3}\..*$ ]]; then
VERSION="v$VERSION"
VERSION=$(echo ${VERSION} | tr x \*)
VERSION=$(git ls-remote --tags --refs ${LANGUAGE_REPO} | sed 's/.*\///' | grep ${VERSION} | tail -n1)
if [ -z $VERSION ]; then
echo -e "${RED}Installation is failed: ${BOLD_PURPLE}${LANGUAGE_NAME}${RED} version ${BOLD_PURPLE}${VERSION_ORIG}${RED} does not exists!${NC}"
exit 13
else
VERSION_ORIG=${VERSION:1}
fi
printf "Installing ${BOLD_PURPLE}${LANGUAGE_NAME}${NC} version ${BOLD_PURPLE}${VERSION_ORIG}${NC} to the system\n"
else
printf "Installing ${BOLD_PURPLE}${LANGUAGE_NAME}${NC} branch ${BOLD_PURPLE}${VERSION_ORIG}${NC} to the system\n"
fi
fi
spinner &
SPINNER_PID=$!
INSTALLATION_FAIL=false
OUT_BUFFER=$(mktemp -t occultist-XXXXXXXXXX)
LANGUAGE_CLONE_DIR="/tmp/$LANGUAGE_BINARY.$RANDOM"
{
if [ -z $VERSION ]; then
BRANCH=$(get_latest_tag_or_default_branch ${LANGUAGE_REPO})
else
BRANCH=$VERSION
fi
git clone --depth=1 --branch $BRANCH $LANGUAGE_REPO $LANGUAGE_CLONE_DIR && \
cd $LANGUAGE_CLONE_DIR && \
if [ "$PLATFORM" = "Mac" ]; then
sudo -u $SUDO_USER make requirements
source ~/.bash_profile
else
make_c requirements
fi
make_c && \
make_c install || INSTALLATION_FAIL=true
cd $THIS_DIR
rm -rf $LANGUAGE_CLONE_DIR
} &> $OUT_BUFFER
kill -9 $SPINNER_PID
wait $SPINNER_PID 2>/dev/null
printf "\b"
if [ $INSTALLATION_FAIL = true ]; then
cat $OUT_BUFFER
echo -e "${RED}Installation is failed!${NC}"
exit 11
fi
echo -e "${GREEN}Installation is successful.${NC}"
return 0
}
uninstall_language() {
if [ ! "$PLATFORM" = "MinGw" ]; then
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}To uninstall ${LANGUAGE_NAME} you need to run this command as root!${NC}"
exit 10
fi
else
if [ ! "$(mingw_is_admin)" = "admin" ]; then
echo -e "${RED}To uninstall ${LANGUAGE_NAME} you need to run as administrator!${NC}"
exit 10
fi
fi
UNINSTALLATION_FAIL=false
rm $LANGUAGE_PATH || UNINSTALLATION_FAIL=true
if [ $UNINSTALLATION_FAIL = true ]; then
echo -e "${RED}Uninstallation is failed!${NC}"
exit 12
fi
echo -e "${GREEN}Uninstallation is successful.${NC}"
return 0
}
install_spell() {
SPELL_NAME=$1
if [ -z $3 ]; then
VERSION=
LOCK=$2
else
VERSION=$2
LOCK=$3
fi
if [ -z $4 ]; then
:
else
DEPENDENCY_ROOT=$4
fi
if [ ! -f $DEPENDENCY_ROOT/$TRACKER_FILE ]; then
echo -e "[\n]" > $TRACKER_FILE
fi
if [ -z $VERSION ]; then
printf "Installing spell: ${YELLOW}${SPELL_NAME}${NC}\n"
else
printf "Installing spell: ${YELLOW}${SPELL_NAME}${NC}:${YELLOW}${VERSION}${NC}\n"
fi
spinner &
SPINNER_PID=$!
RESPONSE=$(curl -s -w '%{http_code}' -X GET \
$API_BASE/spell/$SPELL_NAME \
-H 'cache-control: no-cache' \
-H 'content-type: application/json')
STATUS_CODE=$(echo $RESPONSE | tail -c 4)
RESPONSE_LENGTH=${#RESPONSE}
RESPONSE=${RESPONSE:0:RESPONSE_LENGTH-3}
CLONE_FAIL=false
BUILD_FAIL=false
if [ $STATUS_CODE -eq 200 ]; then
OUT_BUFFER=$(mktemp -t occultist-XXXXXXXXXX)
{
SPELL_REPO=$(echo ${RESPONSE} | jq -r '.repo')
if [ -z $VERSION ]; then
BRANCH=$(get_latest_tag_or_default_branch ${SPELL_REPO})
BRANCH_ORIG=$BRANCH
else
if [[ $VERSION =~ ^[0-9x]+(\.[0-9x]+){0,3}$ ]] || [[ $VERSION =~ ^[0-9x]+(\.[0-9x]+){0,3}-.*$ ]] || [[ $VERSION =~ ^[0-9x]+(\.[0-9x]+){0,3}\+.*$ ]] || [[ $VERSION =~ ^[0-9x]+(\.[0-9x]+){0,3}\..*$ ]]; then
BRANCH_ORIG="$VERSION"
BRANCH="v$VERSION"
BRANCH=$(echo ${BRANCH} | tr x \*)
BRANCH=$(git ls-remote --tags --refs ${SPELL_REPO} | sed 's/.*\///' | grep ${BRANCH} | tail -n1)
if [ -z $BRANCH ]; then
BRANCH=$BRANCH_ORIG
CLONE_FAIL=true
fi
else
BRANCH=$VERSION
BRANCH_ORIG=$VERSION
fi
fi
SPELL_PATH=$(jq -r ".[] | select(.name == \"${SPELL_NAME}\") | select(.version == \"${BRANCH}\") | .path" ${DEPENDENCY_ROOT}/${TRACKER_FILE} | tail -n1)
mkdir -p $SPELLS_DIR_NAME
cd $SPELLS_DIR_NAME/
if [ -z $SPELL_PATH ]; then
if [ -d "$SPELL_NAME" ]; then rm -rf $SPELL_NAME; fi
git clone --depth=1 --branch $BRANCH $SPELL_REPO $SPELL_NAME || CLONE_FAIL=true
cd $SPELL_NAME
rm -rf .git/
spell_type=$(jq -r '.type' $JSON_FILE)
cat $DEPENDENCY_ROOT/$TRACKER_FILE | jq -r ".[. | length] |= . + {\"name\": \"${SPELL_NAME}\"}" > $TMP_FILE && mv $TMP_FILE $DEPENDENCY_ROOT/$TRACKER_FILE
cat $DEPENDENCY_ROOT/$TRACKER_FILE | jq -r ".[. | length - 1] |= . + {\"version\": \"${BRANCH}\"}" > $TMP_FILE && mv $TMP_FILE $DEPENDENCY_ROOT/$TRACKER_FILE
cat $DEPENDENCY_ROOT/$TRACKER_FILE | jq -r ".[. | length - 1] |= . + {\"path\": \"${THIS_DIR}/${SPELLS_DIR_NAME}/${SPELL_NAME}\"}" > $TMP_FILE && mv $TMP_FILE $DEPENDENCY_ROOT/$TRACKER_FILE
if [ $spell_type = "extension" ]; then
make_c || BUILD_FAIL=true
elif [ $spell_type = "module" ]; then
$PROGRAM_BINARY install $PROGRAM_BINARY $DEPENDENCY_ROOT || BUILD_FAIL=true
fi
else
ln -s $SPELL_PATH $SPELL_NAME
fi
cd $THIS_DIR
if [ $CLONE_FAIL = false ] && [ $BUILD_FAIL = false ]; then
if [ $LOCK = false ]; then
cat $JSON_FILE | jq -r ".dependencies += {\"${SPELL_NAME}\": \"${BRANCH_ORIG}\"}" > $TMP_FILE && mv $TMP_FILE $JSON_FILE
fi
cat $LOCK_FILE | jq -r ".dependencies += {\"${SPELL_NAME}\": \"${BRANCH}\"}" > $TMP_FILE && mv $TMP_FILE $LOCK_FILE
fi
} &> $OUT_BUFFER
kill -9 $SPINNER_PID
wait $SPINNER_PID 2>/dev/null
printf "\b"
if [ $CLONE_FAIL = true ]; then
echo -e "${RED}Installation of ${YELLOW}${SPELL_NAME}${RED} is failed: Version ${YELLOW}${BRANCH}${RED} does not exists!${NC}"
exit 3
elif [ $BUILD_FAIL = true ]; then
rm -rf $SPELLS_DIR_NAME/$SPELL_NAME
cat $OUT_BUFFER
echo -e "${RED}Installation of ${YELLOW}${SPELL_NAME}${NC}:${YELLOW}${BRANCH}${RED} is failed: Build failure!${NC}"
exit 4
fi
echo -e "${GREEN}The spell ${YELLOW}${SPELL_NAME}${NC}:${YELLOW}${BRANCH}${GREEN} is successfully installed.${NC}"
curl -s -o /dev/null -X GET \
$API_BASE/spell/install/$SPELL_NAME \
-H 'cache-control: no-cache' \
-H 'content-type: application/json'
elif [ $STATUS_CODE -eq 404 ]; then
kill -9 $SPINNER_PID
wait $SPINNER_PID 2>/dev/null
printf "\b"
echo -e "${RED}Couldn't find ${YELLOW}${SPELL_NAME}${RED} in the spell index!${NC}"
exit 5
else
kill -9 $SPINNER_PID
wait $SPINNER_PID 2>/dev/null
printf "\b"
echo -e "${RED}Search for the spell is failed!${NC}"
exit 6
fi
if [ -z $4 ]; then
rm $DEPENDENCY_ROOT/$TRACKER_FILE
fi
}
print_help_text() {
read -r -d '' HELP_TEXT << EOF
${YELLOW}Usage:${NC}
${PROGRAM_BINARY} [options] [commands]
${PROGRAM_BINARY} ${GREEN}install${NC} [spell]
${PROGRAM_BINARY} ${GREEN}install${NC} [spell] [version]
${PROGRAM_BINARY} ${GREEN}install${NC} [spell] [branch]
${PROGRAM_BINARY} ${GREEN}upgrade${NC} [spell]
${PROGRAM_BINARY} ${RED}remove${NC} [spell]
${PROGRAM_BINARY} init
${PROGRAM_BINARY} edit
${PROGRAM_BINARY} ${YELLOW}register${NC}
${YELLOW}Special commands:${NC}
${BOLD_RED}${SUDO}${NC}${PROGRAM_BINARY} ${GREEN}install${NC} ${BOLD_PURPLE}${LANGUAGE_BINARY}${NC}
${BOLD_RED}${SUDO}${NC}${PROGRAM_BINARY} ${GREEN}upgrade${NC} ${BOLD_PURPLE}${LANGUAGE_BINARY}${NC}
${BOLD_RED}${SUDO}${NC}${PROGRAM_BINARY} ${RED}remove${NC} ${BOLD_PURPLE}${LANGUAGE_BINARY}${NC}
${BOLD_RED}${SUDO}${NC}${PROGRAM_BINARY} ${GREEN}upgrade${NC} ${BOLD_YELLOW}${PROGRAM_BINARY}${NC}
${BOLD_RED}${SUDO}${NC}${PROGRAM_BINARY} ${RED}remove${NC} ${BOLD_YELLOW}${PROGRAM_BINARY}${NC}
${YELLOW}Options:${NC}
${GREEN} -h, --help ${NC}Display this help message.
${GREEN} -l, --license ${NC}Display the license.
${GREEN} -n, --no-update ${NC}Disable check for updates.
${YELLOW}Command Descriptions:${NC}
${GREEN} install ${NC}Install a spell. Optionally specify version or branch.
${GREEN} upgrade ${NC}Upgrade the spell according to the version in ${JSON_FILE} file.
${GREEN} remove ${NC}Uninstall a spell.
${GREEN} init ${NC}Generate a new ${JSON_FILE} file automatically by answering the questions.
${GREEN} edit ${NC}Edit an existing ${JSON_FILE} file.
${GREEN} register ${NC}Register a new spell to The ${LANGUAGE_NAME_SHORT} Spell Index.
EOF
echo -e "$HELP_TEXT"
exit 0
}
check_for_updates() {
printf "Checking for updates...\n"
spinner &
SPINNER_PID=$!
curl -s -o /tmp/${PROGRAM_BINARY} -L ${PROGRAM_RAW_URL}
checksum1=$(md5sum ${PROGRAM_PATH} | awk '{ print $1 }')
checksum2=$(md5sum /tmp/${PROGRAM_BINARY} | awk '{ print $1 }')
kill -9 $SPINNER_PID
wait $SPINNER_PID 2>/dev/null
printf "\b"
if [ ! "$checksum1" = "$checksum2" ]; then
read -r -d '' UPGRADE_TEXT << EOF
${RED}A new version of ${PROGRAM} is available! Run:${NC}
${SUDO}${PROGRAM_BINARY} upgrade ${PROGRAM_BINARY}\n
EOF
echo -e "$UPGRADE_TEXT"
exit 15
else
echo -e "${GREEN}${PROGRAM} is up to date.${NC}"
fi
}
install_requirements() {
if [[ "$OSTYPE" == "linux"* ]]; then
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}There are missing requirements for ${PROGRAM}!${NC}"
echo -e "${RED}To install the requirements you need to run this command as root!${NC}"
exit 17
fi
printf "Installing requirements...\n"
spinner &
SPINNER_PID=$!
{
APT_CMD=$(which apt)
APT_GET_CMD=$(which apt-get)
YUM_CMD=$(which yum)
DNF_CMD=$(which dnf)
PACMAN_CMD=$(which pacman)
APK_CMD=$(which apk)
REQUIREMENTS='git jq curl'
if [[ ! -z $APT_CMD ]]; then
apt update && \
apt install -y $REQUIREMENTS
elif [[ ! -z $APT_GET_CMD ]]; then
apt-get update && \
apt-get install -y $REQUIREMENTS
elif [[ ! -z $YUM_CMD ]]; then
yum install -y $REQUIREMENTS
elif [[ ! -z $DNF_CMD ]]; then
dnf install -y $REQUIREMENTS
elif [[ ! -z $PACMAN_CMD ]]; then
pacman -Syu --noconfirm && \
pacman -S --noconfirm $REQUIREMENTS
elif [[ ! -z $APK_CMD ]]; then
apk update && \
apk add $REQUIREMENTS
else
echo "Error: Automatic detection of default package manager is failed!"
exit 1;
fi
} &> /dev/null
kill -9 $SPINNER_PID
wait $SPINNER_PID 2>/dev/null
printf "\b"
elif [[ "$OSTYPE" == "darwin"* ]]; then
printf "Installing requirements...\n"
spinner &
SPINNER_PID=$!
{
brew update
brew install git jq md5sha1sum curl
} &> /dev/null
kill -9 $SPINNER_PID
wait $SPINNER_PID 2>/dev/null
printf "\b"
fi
}
check_requirements() {
which git &>/dev/null
CHECK_GIT=$?
which jq &>/dev/null
CHECK_JQ=$?
which md5sum &>/dev/null
CHECK_MD5SUM=$?
which curl &>/dev/null
CHECK_CURL=$?
if [ ! $CHECK_GIT -eq 0 ] || [ ! $CHECK_JQ -eq 0 ] || [ ! $CHECK_MD5SUM -eq 0 ] || [ ! $CHECK_CURL -eq 0 ]; then
install_requirements
fi
}
upgrade_dependency_manager() {
if [ ! "$PLATFORM" = "MinGw" ]; then
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}To remove ${PROGRAM} you need to run this command as root!${NC}"
exit 16
fi
else
if [ ! "$(mingw_is_admin)" = "admin" ]; then
echo -e "${RED}To remove ${PROGRAM} you need to run as administrator!${NC}"
exit 10
fi
fi
printf "Upgrading ${YELLOW}${PROGRAM_BINARY}${NC}...\n"
TMP_DOWNLOAD_PATH=$(mktemp -t occultist-XXXXXXXXXX)
spinner &
SPINNER_PID=$!
curl -s -o ${TMP_DOWNLOAD_PATH} -L ${PROGRAM_RAW_URL}
kill -9 $SPINNER_PID
wait $SPINNER_PID 2>/dev/null
printf "\b"
echo -e "${GREEN}${PROGRAM} is successfully upgraded.${NC}"
chmod u=rwx,g=rx,o=rx ${TMP_DOWNLOAD_PATH}
mv ${TMP_DOWNLOAD_PATH} ${PROGRAM_PATH}
}
remove_dependency_manager() {
if [ ! "$PLATFORM" = "MinGw" ]; then
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}To upgrade ${PROGRAM} you need to run this command as root!${NC}"
exit 16
fi
else
if [ ! "$(mingw_is_admin)" = "admin" ]; then
echo -e "${RED}To upgrade ${PROGRAM} you need to run as administrator!${NC}"
exit 10
fi
fi
REMOVE_FAIL=false
rm $PROGRAM_PATH || REMOVE_FAIL=true
if [ $REMOVE_FAIL = true ]; then
echo -e "${RED}Failed to remove ${PROGRAM}!${NC}"
exit 17
fi
echo -e "${GREEN}${PROGRAM} is successfully removed.${NC}"
return 0
}
if [ "$#" -lt 1 ] || [ $1 = "-h" ] || [ $1 = "--help" ]; then
print_help_text
fi
if [ "$#" -lt 2 ] || [ ! $1 = "upgrade" ] || [ ! $2 = "$PROGRAM_BINARY" ]; then
check_requirements
if [ "$1" = "-n" ] || [ "$1" = "--no-update" ]; then
shift
else
check_for_updates
fi
fi
# Create or edit $JSON_FILE
if [ $1 = "init" ] || [ $1 = "edit" ] || [ $1 = "create" ]; then
if [ ! -f $JSON_FILE ]; then
echo -e "{\n}" > $JSON_FILE
fi
{
if cat $JSON_FILE | jq -e 'has("dependencies")'; then
:
else
cat $JSON_FILE | jq -r '. += {"dependencies": {}}' > $TMP_FILE && mv $TMP_FILE $JSON_FILE
fi
} &> /dev/null
read -p "$(echo -e ${YELLOW}Spell name: ${NC}${BOLD_NC})" spell_name
read -p "$(echo -e ${YELLOW}Spell version: ${NC}${BOLD_NC})" spell_version
read -p "$(echo -e ${YELLOW}Spell description: ${NC}${BOLD_NC})" spell_description
echo -e "${UNDERLINED_NC}Select the spell type${NC}"
PS3="Pick an option: "
options=("module" "extension")
select opt in "${options[@]}"; do
case "$REPLY" in
1 ) spell_type=$opt; echo -e "${YELLOW}Spell type: ${NC}${BOLD_NC}${opt}${NC}"; break;;
2 ) spell_type=$opt; echo -e "${YELLOW}Spell type: ${NC}${BOLD_NC}${opt}${NC}"; break;;
*) echo "Invalid option. Try another one.";continue;;
esac
done
read -p "$(echo -e ${YELLOW}License: ${NC}${BOLD_NC})" license
read -p "$(echo -e ${YELLOW}Author name: ${NC}${BOLD_NC})" author_name
read -p "$(echo -e ${YELLOW}Author email: ${NC}${BOLD_NC})" author_email
echo -e "${UNDERLINED_NC}Select the author's role${NC}"
PS3="Pick an option: "
options=("maintainer" "developer")
select opt in "${options[@]}"; do
case "$REPLY" in
1 ) author_role=$opt; echo -e "${YELLOW}Author role: ${NC}${BOLD_NC}${opt}${NC}"; break;;
2 ) author_role=$opt; echo -e "${YELLOW}Author role: ${NC}${BOLD_NC}${opt}${NC}"; break;;
*) echo "Invalid option. Try another one.";continue;;
esac
done
cat $JSON_FILE | jq -r ". += {\"name\": \"${spell_name}\"}" > $TMP_FILE && mv $TMP_FILE $JSON_FILE
cat $JSON_FILE | jq -r ". += {\"version\": \"${spell_version}\"}" > $TMP_FILE && mv $TMP_FILE $JSON_FILE
cat $JSON_FILE | jq -r ". += {\"description\": \"${spell_description}\"}" > $TMP_FILE && mv $TMP_FILE $JSON_FILE
cat $JSON_FILE | jq -r ". += {\"tags\": []}" > $TMP_FILE && mv $TMP_FILE $JSON_FILE
cat $JSON_FILE | jq -r ". += {\"type\": \"${spell_type}\"}" > $TMP_FILE && mv $TMP_FILE $JSON_FILE
cat $JSON_FILE | jq -r ". += {\"license\": \"${license}\"}" > $TMP_FILE && mv $TMP_FILE $JSON_FILE
cat $JSON_FILE | jq -r ". += {\"authors\": []}" > $TMP_FILE && mv $TMP_FILE $JSON_FILE
cat $JSON_FILE | jq -r ".authors[0] += {\"name\": \"${author_name}\"}" > $TMP_FILE && mv $TMP_FILE $JSON_FILE
cat $JSON_FILE | jq -r ".authors[0] += {\"email\": \"${author_email}\"}" > $TMP_FILE && mv $TMP_FILE $JSON_FILE
cat $JSON_FILE | jq -r ".authors[0] += {\"role\": \"${author_role}\"}" > $TMP_FILE && mv $TMP_FILE $JSON_FILE
dependencies=$(jq -r '.dependencies' $JSON_FILE)
jq -M "del(.dependencies)" $JSON_FILE > tmp && mv tmp $JSON_FILE
cat $JSON_FILE | jq -r ". += {\"dependencies\": ${dependencies}}" > $TMP_FILE && mv $TMP_FILE $JSON_FILE
# Register the spell
elif [ $1 = "register" ]; then
SPELL_NAME=$(jq -r '.name' $JSON_FILE)
SPELL_VERSION=$(jq -r '.version' $JSON_FILE)
SPELL_DESCRIPTION=$(jq -r '.description' $JSON_FILE)
SPELL_TAGS_READABLE=$(jq -r '.tags | reduce .[1:][] as $i ("\(.[0])"; . + ", \($i)" )' $JSON_FILE)
SPELL_TYPE=$(jq -r '.type' $JSON_FILE)
SPELL_LICENSE=$(jq -r '.license' $JSON_FILE)
SPELL_REPO=$(git config --get remote.origin.url)
printf "%-20s ${YELLOW}%-20s${NC}\n" "Spell name:" "$SPELL_NAME"
printf "%-20s ${YELLOW}%-20s${NC}\n" "Spell version:" "$SPELL_VERSION"
printf "%-20s ${YELLOW}%-20s${NC}\n" "Spell description:" "$SPELL_DESCRIPTION"
printf "%-20s ${YELLOW}%-20s${NC}\n" "Spell tags:" "$SPELL_TAGS_READABLE"
printf "%-20s ${YELLOW}%-20s${NC}\n" "Spell type:" "$SPELL_TYPE"
printf "%-20s ${YELLOW}%-20s${NC}\n" "Spell license:" "$SPELL_LICENSE"
printf "%-20s ${YELLOW}%-20s${NC}\n" "Spell repository:" "$SPELL_REPO"
spinner &
SPINNER_PID=$!
STATUS_CODE=$(curl -s -o /dev/null -w '%{http_code}' -X POST \
$API_BASE/spell/create \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d "{
\"name\": \"$SPELL_NAME\",
\"repo\": \"$SPELL_REPO\"
}")
kill -9 $SPINNER_PID
wait $SPINNER_PID 2>/dev/null
printf "\b \n"
if [ $STATUS_CODE -eq 200 ]; then
echo -e "${GREEN}The spell is successfully registered!${NC}"
exit 0
elif [ $STATUS_CODE -eq 409 ]; then
echo -e "${YELLOW}The spell is already registered!${NC}"
exit 2
else
echo -e "${RED}Spell registration is failed!${NC}"
exit 1
fi
# Install spells
elif [ $1 = "install" ]; then
if [ ! -f $JSON_FILE ]; then
echo -e "{\n}" > $JSON_FILE
fi
{
if cat $JSON_FILE | jq -e 'has("dependencies")'; then
:
else
cat $JSON_FILE | jq -r '. += {"dependencies": {}}' > $TMP_FILE && mv $TMP_FILE $JSON_FILE
fi
LOCK=true
if [ ! -f $LOCK_FILE ]; then
echo -e "{\n}" > $LOCK_FILE
LOCK=false
fi
if cat $LOCK_FILE | jq -e 'has("dependencies")'; then
:
else
cat $LOCK_FILE | jq -r '. += {"dependencies": {}}' > $TMP_FILE && mv $TMP_FILE $LOCK_FILE
fi
} &> /dev/null
# Install all the dependencies
if [ -z $2 ] || [ $2 = "$PROGRAM_BINARY" ]; then
if [ $LOCK = true ]; then
SUBJECT_FILE=$LOCK_FILE
else
SUBJECT_FILE=$JSON_FILE
fi
while IFS== read -r key value; do
install_spell $key $value $LOCK $3
done < <(jq -r '.dependencies | to_entries | .[] | .key + "=" + .value ' $SUBJECT_FILE)
# Install and save a specific spell
else
if [ $2 = $LANGUAGE_BINARY ]; then
install_language $3
else
install_spell $2 $3 false
fi
fi
# Upgrade the spells
elif [ $1 = "upgrade" ]; then
LOCK=false
# Upgrade all the dependencies
if [ -z $2 ]; then
while IFS== read -r key value; do
install_spell $key $value $LOCK
done < <(jq -r '.dependencies | to_entries | .[] | .key + "=" + .value ' $JSON_FILE)
# Upgrade and save a specific spell
else
if [ $2 = $LANGUAGE_BINARY ]; then
install_language $3
elif [ $2 = $PROGRAM_BINARY ]; then
upgrade_dependency_manager
else
SPELL_NAME=$2
BRANCH=$(jq -r ".dependencies.${SPELL_NAME}" $JSON_FILE)
install_spell $SPELL_NAME $BRANCH $LOCK
fi
fi
# Remove a spell
elif [ $1 = "remove" ]; then
LOCK=false
if [ -z $2 ]; then
echo -e "\n${RED}You have to specifiy a spell name!${NC}\n"
exit 7
else
if [ $2 = $LANGUAGE_BINARY ]; then
uninstall_language
elif [ $2 = $PROGRAM_BINARY ]; then
remove_dependency_manager
else
SPELL_NAME=$2
IS_SPELL_EXISTS=false
{
IS_SPELL_EXISTS=$(cat $JSON_FILE | jq -e ".dependencies | has(\"${SPELL_NAME}\")")
} &> /dev/null
if [ $IS_SPELL_EXISTS = "true" ]; then
cd $SPELLS_DIR_NAME/ && \
rm -rf $SPELL_NAME && \
cd $THIS_DIR && \
rmdir $SPELLS_DIR_NAME/ &> /dev/null
jq -M "del(.dependencies.${SPELL_NAME})" $LOCK_FILE > $TMP_FILE && mv $TMP_FILE $LOCK_FILE && \
jq -M "del(.dependencies.${SPELL_NAME})" $JSON_FILE > $TMP_FILE && mv $TMP_FILE $JSON_FILE && \
echo -e "${GREEN}The spell ${YELLOW}${SPELL_NAME}${GREEN} is successfully removed.${NC}" || \
echo -e "${RED}Failed to remove spell ${YELLOW}${SPELL_NAME}${RED}!${NC}" || \
exit 9
else
echo -e "${RED}Spell ${YELLOW}${SPELL_NAME}${RED} is already removed!${NC}"
exit 8
fi
fi
fi
fi