#!/usr/bin/guile16 -s
!#
(use-modules (ice-9 getopt-long)
	     (alterator common)

	     (alterator algo)
	     (alterator telegraph)
	     (alterator transport pipe-channel)
	     (alterator lookout)
	     (alterator ensign))

(define cmdline (command-line))
(define progname (car cmdline))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (usage progname)
  (format #t "Usage:  ~A [-l] module~%" progname)
  (format #t "  -h, --help     display help screen~%")
  (format #t "  -l,--local     try to use local files (maps,po,layout,etc.) if available ~%~%")
  (format #t "  Report bugs to <inger@altlinux.ru>~%")
  (quit))

(define option-spec
  '((help  (single-char #\h) (value #f))
    (local (single-char #\l) (value #f))))

(define options (getopt-long cmdline option-spec))

(and (option-ref options 'help #f) (usage progname))

(alterator-init)
(and (option-ref options 'local #f) (alterator-init-local))

(define desktop-file (or (cond-car (option-ref options '() #f)) (usage progname)))


(telegraph
  (pipe-in "/usr/bin/alterator-browser-x11")
  (lookout "/standalone" 'desktop-file desktop-file)
  (ensign))

(telegraph-start)
