Moritz Heidkamp  committed 6113a6c

chicken-select: add -v (verbose) option that adds output of (chicken-version #t) to each chicken entry

  • Participants
  • Parent commits 310d01f

Comments (0)

Files changed (1)

File chicken-select.scm

+(define verbose? #f)
+(unless (null? (command-line-arguments))
+  (if (equal? "-v" (car (command-line-arguments)))
+      (set! verbose? #t)
+      (fail "Invalid arguments: ~S" (command-line-arguments))))
 (define (available-chickens)
   (filter (lambda (p) (not (equal? chicken-link p)))
           (directory chicken-coop)))
       (delete-file symlink))
     (create-symbolic-link chicken symlink)))
+(define (print-chicken-version chicken)
+  (let* ((csi (make-pathname chicken-coop chicken))
+         (csi (make-pathname csi "bin"))
+         (csi (make-pathname csi "csi")))
+    (receive (in out pid)
+        (process csi '("-p" "(chicken-version #t)"))
+      (port-for-each 
+       (lambda (line)
+         (printf "     ~A~%" line)) 
+       (lambda () (read-line in)))
+      (close-output-port out)
+      (close-input-port in))))
 (let* ((all-chicks (available-chickens))
        (current (list-index (cut equal? (current-chicken chicken-coop chicken-link) <>) all-chicks)))
   (let select ((abort #f))
           (for-each (lambda (c n)
                       (printf "~a ~a: ~a~%"
                               (if (equal? n current) "*" " ")
-                              n c))
+                              n c)
+                      (when verbose?
+                        (print-chicken-version c)))
                     (iota (length all-chicks)))