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

	     (alterator telegraph)
	     (alterator transport pipe-channel)
	     (alterator lookout)
	     (alterator d))


;;; functions
(define *cmdline* (command-line))

(define (usage)
  (format #t "Usage:  ~A [-ld]~%" (car *cmdline*))
  (format #t "  -h, --help     display help screen~%")
  (format #t "  -l,--local     try to use local ui files if available ~%")
  (format #t "  -d,--debug     turn on debugging~%~%")
  (format #t "  Report bugs to http://bugs.altlinux.org/~%")
  (quit))

;;; main code

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

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

(and (option-ref options 'help #f) (usage))
(and (option-ref options 'debug #f) (turn-on-debugging))

(if (option-ref options 'local #f)
    (begin (alterator-init-local)
           (d-init-local))
    (begin (alterator-init-global)
           (d-init-global)))

(telegraph
  (pipe-in "/usr/bin/alterator-browser-qt")
  (lookout "/acc")
  (d))

(telegraph-start)
