#!/usr/bin/guile -s
!#
(use-modules (ice-9 getopt-long) (ice-9 debug) (srfi srfi-2))

(define datadir "../common/")

(load (string-append datadir "lookout.scm"))
(load (string-append datadir "compat-telegraph.scm"))

;alias woo-query to bus-query
(define woo-query bus-query)

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

(define (usage progname)
  (format #t "Usage:  ~A --map filename~%" progname)
  (format #t "  -h, --help     display help screen~%")
  (format #t "  -v, --version  display version information ~%")
  (format #t "  -m,--map       load default url mapping from the appropriate file~%~%")
  (format #t "  Report bugs to <inger@altlinux.ru>~%")
  #t)

(define (version progname) (format #t "~A version 1.99 ~%" progname) #t)

(define option-spec
  '((version (single-char #\v) (value #f))
    (help    (single-char #\h) (value #f))
    (map  (single-char #\m) (value #t))))

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

(and (option-ref options 'help #f) (usage progname) (quit))
(and (option-ref options 'version #f) (version progname) (quit))
(and-let* ((mapfile (option-ref options 'map #f)))
	  (application (lambda() (lookout-main mapfile)))
	  (write-line exit-address)
	  (quit))
(usage progname)

