-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy path.dune-prelude
executable file
ยท747 lines (665 loc) ยท 21.7 KB
/
.dune-prelude
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
# _
# /\ | |
# / \ __| | __ _ _ __ ___
# / /\ \ / _` |/ _` | '_ ` _ \
# / ____ \ (_| | (_| | | | | | |
# /_/ __\_\__,_|\__,_|_| |_| |_| _ _ _
# | \/ | | __ \ (_) | ( )
# | \ / | ___| | | | __ _ _ __ _ ___| |/ ___
# | |\/| |/ __| | | |/ _` | '_ \| |/ _ \ | / __|
# | | | | (__| |__| | (_| | | | | | __/ | \__ \
# |_|__|_|\___|_____/ \__,_|_|_|_|_|\___|_| |___/
# | __ \ | | | |
# | |__) | __ ___| |_ _ __| | ___
# | ___/ '__/ _ \ | | | |/ _` |/ _ \
# | | | | | __/ | |_| | (_| | __/
# |_| |_| \___|_|\__,_|\__,_|\___|
#
# Overview:
# Splash screen:
# welcome # Prints splash screen
# about # Prints info about the shell
# donate # Prints donation message
#
# Calendar widget:
# cal # Print a calendar
#
# Shrew:
# shrewsay "Message to print" # Makes a wild dune shrew appear!
# turnedshrewsay "Message to print" # Makes a left-facing wild dune shrew appear!
#
# Have fun, scripters!
let $ = GLOB ~> ((fs@ls .) | (fn@filter (file -> (len (string@split GLOB file)) == 2)));
let include = file ~> exec (parse@expr (fs@read file));
let use = file ~> eval (parse@expr (fs@read file));
let get = key -> table -> table@(key);
let open = fs@read;
let concat = x -> y -> (str y) + (str x);
let ssh = addr -> user -> {
'ssh -X (str user) + "@" + (str addr);
};
let scp = addr -> user -> src -> dst -> {
# Call the actual overshadowed scp program
'scp -r src (str user) + "@" + (str addr) + ":" + (str dst)
};
let ~ = x -> HOME + "/" + (str x) | fs@canon;
let OLD-EXIT = exit;
let quit = _ ~> OLD-EXIT 0;
let q = quit;
let exit = quit;
let WEATHER-EMOJIS = {
Unknown= "โจ",
Cloudy= "โ๏ธ",
Fog= "๐ซ",
HeavyRain= "๐ง",
HeavyShowers= "๐ง",
HeavySnow= "โ๏ธ",
HeavySnowShowers= "โ๏ธ",
LightRain= "๐ฆ",
LightShowers= "๐ฆ",
LightSleet= "๐ง",
LightSleetShowers= "๐ง",
LightSnow= "๐จ",
LightSnowShowers= "๐จ",
PartlyCloudy= "โ
๏ธ",
Sunny= "โ๏ธ",
ThunderyHeavyRain= "๐ฉ",
ThunderyShowers= "โ",
ThunderySnowShowers= "โ",
VeryCloudy= "โ๏ธ"
};
let MOON-PHASES = [
"๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐"
];
let WEATHER-ASCII = {
Unknown = " .-.
__)
(
`-โ
โข",
Sunny = " \\ /
.-.
โ ( ) โ
`-โ
/ \\ ",
PartlyCloudy =" \\ /
_ /\"\".-.
\\_( ).
/(___(__)",
Cloudy = "
.--.
.-( ).
(___.__)__)",
VeryCloudy = "
.--.
.-( ).
(___.__)__)",
LightShowers=" _`/\"\".-.
,\\_( ).
/(___(__)
โ โ โ โ
โ โ โ โ",
HeavyShowers = " _`/\"\".-.
,\\_( ).
/(___(__)
โโโโโโโโ
โโโโโโโโ",
LightSnowShowers = " _`/\"\".-.
,\\_( ).
/(___(__)
* * *
* * *",
HeavySnowShowers = " _`/\"\".-.
,\\_( ).
/(___(__)
* * * *
* * * *",
LightSleetShowers = " _`/\"\".-.
,\\_( ).
/(___(__)
โ * โ *
* โ * โ",
ThunderyShowers = " _`/\"\".-.
,\\_( ).
/(___(__)
โกโ โโกโ
โ โ โ โ",
ThunderyHeavyRain = " .-.
( ).
(___(__)
โโโกโโโกโโ
โโโโโกโโโ",
ThunderySnowShowers = " _`/\"\".-.
,\\_( ).
/(___(__)
*โก*โก*
* * *",
LightRain = " .-.
( ).
(___(__)
โ โ โ โ
โ โ โ โ",
HeavyRain = " .-.
( ).
(___(__)
โโโโโโโโ
โโโโโโโโ",
LightSnow = " .-.
( ).
(___(__)
* * *
* * *",
HeavySnow = " .-.
( ).
(___(__)
* * * *
* * * *",
LightSleet = " .-.
( ).
(___(__)
โ * โ *
* โ * โ",
Fog = " _ - _ - _ -
_ - _ - _
_ - _ - _ -"
};
let PLANTS = [" _ _
(_\\_)
(__<_{}
(_/_)
|\\ |
\\\\| /|
\\|//
|/
,.,.,|.,.,.,
^`^`^`^`^`^`",
" .--.
.'_\\/_'.
'. /\\ .'
\"||\"
|| /\\
/\\ ||//\\)
(/\\\\||/
____\\||/____
^`^`^`^`^`^`^",
"
__/)
.-(__(=:
|\\ | \\)
\\ ||
\\||
\\|
____|_______
^`^`^`^`^`^`",
"
_
.\\ /.
< ~O~ >
'/_\\'
\\ | /
\\|/
,.,.,|.,.,.,
^`^`^`^`^`^`"
];
let get-weather-ascii = desc -> {
## DRIZZLE ASCII
if desc == "light intensity drizzle" || desc == "drizzle"
|| desc == "heavy intensity drizzle" || desc == "light intensity drizzle rain"
|| desc == "drizzle rain" || desc == "heavy intensity drizzle rain"
|| desc == "shower rain and drizzle" || desc == "heavy shower rain and drizzle"
|| desc == "shower drizzle"
WEATHER-ASCII@LightShowers
## RAIN ASCII
else if desc == "shower rain" || desc == "ragged shower rain" || desc == "light intensity shower rain"
WEATHER-ASCII@LightShowers
else if desc == "light rain"
WEATHER-ASCII@LightRain
else if desc == "moderate rain" || desc == "heavy intensity shower rain"
WEATHER-ASCII@HeavyShowers
else if desc == "heavy intensity rain" || desc == "very heavy rain" || desc == "extreme rain"
WEATHER-ASCII@HeavyRain
else if desc == "freezing rain"
WEATHER-ASCII@LightSleet
## SNOW ASCII
else if desc == "light snow" || desc == "Snow"
WEATHER-ASCII@LightSnow
else if desc == "Heavy snow"
WEATHER-ASCII@HeavySnow
else if desc == "Sleet"
WEATHER-ASCII@LightSleet
else if desc == "Light shower sleet"
WEATHER-ASCII@LightSleetShowers
else if desc == "Shower sleet" || desc == "Rain and snow"
WEATHER-ASCII@HeavySnowShowers
else if desc == "Light shower snow" || desc == "Light rain and snow"
WEATHER-ASCII@LightSnowShowers
else if desc == "Shower snow" || desc == "Heavy shower snow"
WEATHER-ASCII@HeavySnowShowers
## THUNDER ASCII
else if desc == "thunderstorm with light rain" || desc == "thunderstorm with rain"
|| desc == "ragged thunderstorm" || desc == "thunderstorm with light drizzle"
|| desc == "light thunderstorm" || desc == "thunderstorm"
|| desc == "thunderstorm with drizzle" || desc == "thunderstorm with heavy drizzle"
WEATHER-ASCII@ThunderyShowers
else if desc == "thunderstorm with heavy rain" || desc == "heavy thunderstorm"
WEATHER-ASCII@ThunderyHeavyRain
## CLEAR ASCII
else if desc == "clear sky"
WEATHER-ASCII@Sunny
else if desc == "few clouds"
WEATHER-ASCII@PartlyCloudy
else if desc == "scattered clouds"
WEATHER-ASCII@Cloudy
else if desc == "broken clouds"
WEATHER-ASCII@Cloudy
else if desc == "overcast clouds"
WEATHER-ASCII@VeryCloudy
else if desc == "mist" || desc == "Smoke"
|| desc == "Haze" || desc == "sand/ dust whirls" || desc == "fog"
|| desc == "sand" || desc == "dust" || desc == "volcanic ash"
|| desc == "squalls" || desc == "tornado"
WEATHER-ASCII@Fog
else WEATHER-ASCII@Unknown
};
let reload-weather-api = _ ~> {
let weather-api = units -> city -> {
# Confirm that the API key is not None
if WEATHER-API-KEY == None {
# If so, print error message
echo (fmt@italics (fmt@red "Please set your `openweathermap.org` API key with the `set-weather-api-key` macro!"))
} else {
# If not, use the key, download the JSON with CURL, and parse it into a table!
let BASE_URL = "http://api.openweathermap.org/data/2.5/weather?q=";
let URL = BASE_URL + (str city) + "&units=" + (str units) + "&appid=" + (str WEATHER-API-KEY);
# Download and parse JSON into table
curl --silent URL | parse@json
}
};
let weather = units -> city -> {
# Check for proper unit parameter
if (str units) == "imperial" || (str units) == "metric" {
# Get the weather info from openweathermap.org
let weather-data = weather-api units city;
# Check that it was successful
if weather-data != None {
# Get the correct units of temperature
let unit-symbol = if (str units) == "imperial" {
"ยฐ F"
} else {
"ยฐ C"
};
# Get the description of the weather from the weather API JSON
let weather-desc = weather-data@weather@0@description;
# Get the ascii art associated with it
let weather-ascii = get-weather-ascii weather-desc;
# Get the stats widget content as a string
let stats-text = join "\n" [
"Temp now: " + (str weather-data@main@temp) + unit-symbol,
" โณ high: " + (str weather-data@main@temp_max) + unit-symbol,
" โณ low: " + (str weather-data@main@temp_min) + unit-symbol,
"Humidity: " + (str weather-data@main@humidity) + "%",
"Pressure: " + (str weather-data@main@pressure) + " hPa"
];
# Get the header widget content
let header-text = "Weather in " + weather-data@name + ", at " + (time@now ())@time@str
+ ". Description: " + weather-data@weather@0@main;
# Return the widget!
widget@joiny
(widget@create "Weather" header-text 36 4)
(widget@joinx
(widget@create "Stats" stats-text 21 7)
(widget@create "Icon" weather-ascii 15 7))
} else {
echo (fmt@red "could not get weather data");
widget@joiny
(widget@create "Weather" "?" 36 4)
(widget@joinx
(widget@create "Stats" "?" 21 7)
(widget@create "Icon" WEATHER-ASCII@Unknown 15 7))
}
} else {
echo (fmt@red "`units` must be either `imperial` or `metric`");
widget@joiny
(widget@create "Weather" "?" 36 4)
(widget@joinx
(widget@create "Stats" "?" 21 7)
(widget@create "Icon" WEATHER-ASCII@Unknown 15 7))
}
};
};
let set-weather-api-key = WEATHER-API-KEY ~> {
# echo (fmt@green "Set weather API key to " + (str WEATHER-API-KEY) + "!");
reload-weather-api ();
};
set-weather-api-key None;
if os@name == "windows" {
let ls = dir ~> fs@ls dir | join "\n" | echo;
let rm = fs@rm;
let cp = fs@cp;
let mv = fs@mv;
let mkdir = fs@mkdir;
let rmdir = fs@rmdir;
let cat = fs@read;
} else {
if (fs@exists? HOME + "/.cargo/bin/bat") {
let cat = 'bat;
}
if (fs@exists? HOME + "/.cargo/bin/lsd") {
let ls = 'lsd;
}
}
console@title "Dune";
let donate = _ ~> {
echo " โโโโโโโWild Dune Shrewโโโโโโโ
Hello, how is Dune working
for you so far? If you like
it, consider starring our
GitHub page and donating!";
echo " " (fmt@italics "(To remove this message,\n write your own prelude)\n");
echo " " (fmt@href "https://github.com/adam-mcdaniel/dune" "Thank Youโค๏ธ");
echo " โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฑ
โฑ
_,____ c--.
/` \\ ` _^_\\
`~~~\\ _/---'\\\\ ^
`~~~ ~~
โโโโโโโโโโโโโโโโโโโโโ
"
};
let CATS = ["
_
|\\'/-..--.
/ _ _ , ;
`~=`Y'~_<._./
<`-....__.'",
"
|\\__/,| (`\\
|_ _ |.--.) )
( T ) /
(((^_(((/(((_/",
"
\\ /\\
) ( ')
( / )
\\(__)|",
"
^~^ ,
('Y') )
/ \\/
(\\|||/)",
" . .
\\`-\"'\"-'/
} 6 6 {
=. Y ,=
/^^^\\ .
/ \\ )
( )-( )/
\"\" \"\"",
"
/\\_/\\
____/ o o \\
/~____ =Y= /
(______)__m_m)"
];
let prompt = cwd -> fmt@bold ((fmt@dark@blue "(dune) ") + (fmt@bold (fmt@dark@green cwd)) + (fmt@bold (fmt@dark@blue "$ ")));
let incomplete_prompt = cwd -> ((len cwd) + (len "(dune) ")) * " " + (fmt@bold (fmt@dark@yellow "> "));
let shrew = _ ~> {
"
_,____ c--.
/` \\ ` _^_\\
`~~~\\ _/---'\\\\ ^
`~~~ ~~
โโโโโโโโโโโโโโโโโโโโโ
"
};
let turnedshrew = _ ~> {
"
.--p_____,_
/_^_ ` / `\\
^ //'---\\_ /~~~
~~ ~~~`
โโโโโโโโโโโโโโโโโโ
"
};
let shrewsay = text -> {
let title = "Wild Dune Shrew";
let text = (std@string@to-string text);
let cols = math@min (math@max ((console@width ()) // 2) (string@get-width text)) (console@width ());
let text = fmt@wrap text cols;
let text-lines = lines text;
if (len text-lines) == 1 {
if (len text) < cols {
let cols = len text;
}
}
let cols = math@max cols (len title);
let rows = len text-lines;
let spacing = 25;
for line in (lines (widget@create title text cols + 2 rows + 2)) {
echo " " * spacing line;
}
for i in 0 to 2 {
echo " " * (spacing - i) "โฑ";
}
echo (shrew ());
};
let turnedshrewsay = text -> {
let title = "Wild Dune Shrew";
let text = (std@string@to-string text);
let text = (std@string@to-string text);
let cols = math@min (math@max ((console@width ()) // 2) (string@get-width text)) (console@width ());
let text = fmt@wrap text cols;
let text-lines = lines text;
if (len text-lines) == 1 {
if (len text) < cols {
let cols = len text;
}
}
let cols = math@max cols (len title);
let rows = len text-lines;
let spacing = 20;
for line in (lines (widget@create title text cols + 2 rows + 2)) {
echo " " * spacing line;
}
for i in 0 to 2 {
echo " " * (spacing - i) "โฑ";
}
echo (turnedshrew ());
};
let about = _ ~> {
echo (
widget@joiny
(widget@create "About"
" Hello, welcome to " + (fmt@yellow "Dune Shell!") + "
Written by: http://adam-mcdaniel.net\n\nI wrote Dune to be a nice environment for devs while they work! It's a very cozy shell with high customizability, so you can make it how you'd like." 50 10)
(widget@joinx
(widget@create "Features"
"Dune has a wide set of
features, it's basically a
full blown language!
It supports several uncommon
features in a shell, such as:
operator overloading,
lambdas, macros, quoted
expressions like Lisp, and
more!
Dune's libraries are very
extensive. There are
libraries for:
โ A simple widget system๐ช
โ OS information ๐ฝ
โ Randomness ๐
โ Basic math, trig, etc.๐งฎ
โ File system operations๐
โ Text color and styling๐
โ Functional programming๐
โ Date and time ๐
And more!"
30 28)
(widget@joiny
(widget@create "About the Author" "I'm a sophomore at\nthe University of\nTennessee๐ด๓ ต๓ ณ๓ ด๓ ฎ๓ ฟ\nstudying Computer๐ป\nScience๐งช.\n\nI'm extremely \ninterested in\nlanguage design\n& compiler design.\nCheck out my other\nprojects on GitHub:\n\nadam-mcdaniel" 20 18)
(widget@create "Cat" (rand@choose CATS) 20 10)
)))
};
let welcomebanner = _ ~> {
let logo = "
โโโโโโโ โโโ โโโโโโโ โโโโโโโโโโโ
โโโโโโโโโโโ โโโโโโโโ โโโโโโโโโโโ
โโโ โโโโโโ โโโโโโโโโ โโโโโโโโโ
โโโ โโโโโโ โโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโ
โโโโโโโ โโโโโโโ โโโ โโโโโโโโโโโโโ
";
let logo = "
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
";
(_ -> {
let now = time@now ();
let time-emoji = if now@hour <= 6 "๐"
else if now@hour <= 10 "๐
"
else if now@hour <= 18 "๐ค๏ธ "
else "๐";
let date-emoji = if now@month == 1 "โ"
else if now@month == 2 "๐"
else if now@month == 3 "๐"
else if now@month == 4 "๐"
else if now@month == 5 "๐ป"
else if now@month == 6 "๐"
else if now@month == 7 "๐"
else if now@month == 8 "๐"
else if now@month == 9 "๐"
else if now@month == 10 "๐"
else if now@month == 11 "๐"
else if now@month == 12 "๐จ๏ธ"
else "๐
";
let zodiac-emoji = if now@month == 1 (if now@day < 20 "๐" else "๐บ")
else if now@month == 2 (if now@day < 19 "๐บ" else "๐")
else if now@month == 3 (if now@day < 21 "๐" else "๐")
else if now@month == 4 (if now@day < 20 "๐" else "๐")
else if now@month == 5 (if now@day < 21 "๐" else "๐ฌ")
else if now@month == 6 (if now@day < 21 "๐ฌ" else "๐ฆ")
else if now@month == 7 (if now@day < 23 "๐ฆ" else "๐ฆ")
else if now@month == 8 (if now@day < 23 "๐ฆ" else "๐ฉ")
else if now@month == 9 (if now@day < 23 "๐ฉ" else "โ๏ธ")
else if now@month == 10 (if now@day < 23 "โ๏ธ" else "๐ฆ")
else if now@month == 11 (if now@day < 22 "๐ฆ" else "๐น")
else if now@month == 12 (if now@day < 22 "๐น" else "๐")
else "โญ";
echo "โโโโโโโโโโโโโโโโโโWelcome to ...โโโโโโโโโโโโโโโโโโ";
for ch in (string@chars logo) {
print (fmt@bold (if ch == "โ" {
fmt@faint (fmt@red ch)
} else {
fmt@faint (fmt@dark@blue ch)
}));
}
echo "";
echo " The time is " + (fmt@magenta now@time@str) + " " + time-emoji + " on " + (fmt@cyan now@date@str);
echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ";
}) ();
};
let is-leapyear = year -> {
if year % 4 == 0 && year % 100 != 0 {
True
} else if year % 100 == 0 && year % 400 == 0 {
True
} else {
False
}
};
let days-in-month = month -> year -> {
if month == 2 {
28 + (if (is-leapyear year) 1 else 0)
} else {
31 - (((month - 1) % 7) % 2)
}
};
let day-of-week = m -> d -> y -> {
let t = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4];
if m < 3 {
let y = y - 1
}
(((y + (int(y // 4.0))) - (int(y // 100.0))) + (int(y // 400.0)) + t@(m - 1) + d) % 7
};
let WEEKDAYS = [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
];
let MONTHS = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
];
let make-calendar = m -> d -> y -> {
let now = {month=m, day=d, year=y};
let result = MONTHS@(now@month - 1) + " " + (str now@day) + ", " + (str now@year) + "\n";
let result = " " * ((28 - (len result)) // 2 + 1) + result;
let result = result + " Su Mo Tu We Th Fr Sa\n";
let dof = day-of-week now@month 1 now@year;
let dim = days-in-month now@month now@year;
for i in 0 to dof {
let result = result + " ";
}
for i in 1 to dim + 1 {
let num = str i;
if (len num) < 2 {
let num = (if now@day == i " *" else " ") + num
} else {
let num = (if now@day == i "*" else " ") + num
}
let result = result + num + (if (i + dof) % 7 == 0 "\n" else " ")
}
widget@create "Calendar" result 30 10
};
let cal = _ ~> {
(_ -> {
let now = time@now ();
make-calendar now@month now@day now@year
}) ();
};
let dashboard = _ ~> {
reload-weather-api ();
let now = time@now ();
let weather-widget = weather imperial CITY;
welcomebanner ();
echo (widget@joiny
(widget@joinx
(make-calendar now@month now@day now@year)
(widget@create "Cat" (rand@choose CATS) 20 10))
(widget@joinx
(widget@create "Flower" (rand@choose PLANTS) 14 11)
weather-widget))
};
let welcome = _ ~> {
dashboard ();
};
let DUNE_SECRETS_FILE = HOME + "/.dune-secrets";
clear ();
if (fs@exists? DUNE_SECRETS_FILE) {
include DUNE_SECRETS_FILE;
}
let CITY = Knoxville;
welcome ();
if (!(fs@exists? DUNE_SECRETS_FILE)) {
shrewsay "Create " + DUNE_SECRETS_FILE + " to store your secrets, tokens, and API keys!";
}