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

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

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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (usage progname)
  (format #t "Usage:  ~A [-l]~%" progname)
  (format #t "  -h, --help     display help screen~%")
  (format #t "  -f, --file     file with list of steps~%")
  (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))
    (file  (single-char #\f) (value #t))
    (local (single-char #\l) (value #f))))

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

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

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

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

(define *steps-file* (option-ref options 'file "/usr/share/install2/installer-steps"))

(telegraph
  (pipe-in "/usr/bin/alterator-browser-qt" "/tmp")
  (lookout "/wizard" 'steps-file *steps-file*)
  (logfile "/tmp/wizard.log")
  (d))

(telegraph-start)
