Removed imports.
[microbotany.git] / directory.gmi
1 # Garden Directory
2
3 ```
4 ,(eval (begin
5          (import (chicken io)
6                  (chicken file)
7                  (chicken string)
8                  (chicken pathname)
9                  (chicken time posix)
10                  srfi-1 srfi-13)
11          (for-each eval (with-input-from-file "garden.scm" read-list))
12          (define (pad-string o max-len)
13            (let* ((s (->string o))
14                   (n (string-length s)))
15              (if (> n max-len)
16                  (string-take s max-len)
17                  (conc s (make-string (- max-len n) #\space)))))
18          (define (print-rule n)
19            (print (make-string n #\-)))
20          (let* ((headers '("Owner" "Created" "Plant Stage"))
21                 (colwidths '(20 30 15))
22                 (total-width (apply + colwidths)))
23            (apply print (map pad-string headers colwidths))
24            (print-rule total-width)
25            (for-each
26             (lambda (garden-file)
27               (let ((g (with-input-from-file garden-file read)))
28                 (update-garden! g)
29                 (with-output-to-file garden-file (lambda () (write g)))
30                 (let ((fields (list (garden-prop 'user g)
31                                     (seconds->string (garden-prop 'created g))
32                                     (garden-stage g))))
33                   (apply print (map pad-string fields colwidths)))))
34             (glob "accounts/*"))
35            (print-rule total-width))))
36 ```
37
38 => ./ Return to the μBotany start page