Initial functionality, basic client, data model and startup
[candle] / bin / candle-server
1 #!/usr/bin/sbcl --script
2   
3 (setf *compile-print* nil)
4 (require 'asdf)
5 (asdf:initialize-source-registry
6  `(:source-registry (:tree ,(car (directory "src"))) :INHERIT-CONFIGURATION))
7 (asdf:load-system :candle)
8 (asdf:load-system :opera)
9
10 (defpackage #:candle-server-cli (:use #:common-lisp))
11 (in-package #:candle-server-cli)
12
13 (defvar *options*
14  '((:name :help :short "h" :long "help" :description "Print this usage.")
15    (:name :port :short "p" :long "port" :takes-argument t :variable-name "PORT"
16     :description "Port on which to listen for commands.  Defaults to 25004")))
17
18 (defun usage ()
19  (format t "~A"
20   (opera:usage
21    "candle-server"
22    *options*
23    "Starts a candle continuous integration server.  Use 'candle' to interact with the server.")))
24
25 (multiple-value-bind (options remaining-args error) (opera:process-arguments *options* (cdr sb-ext:*posix-argv*))
26  (cond
27   ((opera:option-present :help options) (usage))
28   (remaining-args
29    (format *error-output* "Don't understand ~A.  See 'candle-server -h'~%" (car remaining-args))
30    (sb-ext:exit :code 1))
31   ((and (opera:option-present :port options) (not (parse-integer (opera:option-argument :port options) :junk-allowed t)))
32    (format *error-output* "--port requires a number.  See 'candle-server -h'~%"))
33   (t
34    (let
35     ((port (or (and
36                 (opera:option-present :port options)
37                 (parse-integer (opera:option-argument :port options) :junk-allowed t))
38             25004)))
39    (format t "Starting server on port ~A~%" port)
40    (candle:server port nil)))))
41
42 ; vim:ft=lisp