blob: b1343113449c6a140190656d66493993d86cea58 (
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
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
|
(def HOME "/home/")
(def PORCH "/porch/")
(def BOWL "/porch/bowl/")
(def USER (first ($ "whoami")))
(def NAME "simon")
(def PRONOUN "he")
(def CAT "
|\ _,,,---,,_
/,`.-'`' -. ;-;;,_
|,4- ) )-,_..;\ ( `'-'
'---''(_/--' `-'\_)
")
(func user-from-path (inp)
(first (rest (rest (split inp "/")))))
; get all users who have a "porch"
(func get-porches ()
(map user-from-path (glob (concat HOME "*" PORCH))))
(func concat-star (inp)
(concat " * " inp))
(func print-porches ()
(map print (map concat-star (get-porches))))
(func get-eats (porch)
(glob (concat HOME porch BOWL "*")))
(func get-porches-with-eats ()
(map get-eats (get-porches)))
(func locate ()
(glob (concat HOME "*" PORCH NAME)))
(func get-random-eats ()
(safe-first
(shuf
(safe-first
(shuf (get-porches-with-eats))))))
(func safe-first (inp)
(if (empty? inp)
()
(first inp)))
(func wander ()
(print (concat "off " PRONOUN " goes!"))
(def current-location (locate))
(if (not (empty? current-location))
(print (concat "need to unlink: " (first current-location))))
; this should probably return and not exit?
(def target-eats (get-random-eats))
(if (and (list? target-eats) (empty? target-eat)) (exit))
(def target-porch (user-from-path target-eats))
) ; end of wander
; options
;(print-porches)
;(print (->string (get-porches-with-eats)))
;(print USER)
;(print (->string (locate)))
(wander)
|