#!/usr/bin/sbcl --script (setf *compile-print* nil) (require 'asdf) (asdf:initialize-source-registry `(:source-registry (:tree ,(car (directory "."))) :INHERIT-CONFIGURATION)) (let ((*error-output* (make-broadcast-stream))) (asdf:load-system :candle)) (asdf:load-system :opera) (defpackage #:candle-server-cli (:use #:common-lisp)) (in-package #:candle-server-cli) (defvar *options* '((:name :help :short "h" :long "help" :description "Print this usage.") (:name :port :short "p" :long "port" :takes-argument t :variable-name "PORT" :description "Port on which to listen for commands. Defaults to 25004") (:name :port :long "candle-dir" :takes-argument t :variable-name "DIR" :description "Directory for candle related data. Will be created if does not exist. Defaults to /opt/candle/"))) (defun usage () (format t "~A" (opera:usage "candle-server" *options* "Starts a candle continuous integration server. Use 'candle' to interact with the server."))) (multiple-value-bind (options remaining-args error) (opera:process-arguments *options* (cdr sb-ext:*posix-argv*)) (cond ((opera:option-present :help options) (usage)) (remaining-args (format *error-output* "Don't understand ~A. See 'candle-server -h'~%" (car remaining-args)) (sb-ext:exit :code 1)) ((and (opera:option-present :port options) (not (parse-integer (opera:option-argument :port options) :junk-allowed t))) (format *error-output* "--port requires a number. See 'candle-server -h'~%")) (t (let ((port (or (and (opera:option-present :port options) (parse-integer (opera:option-argument :port options) :junk-allowed t)) 25004))) (setf candle:*candle-dir* (if (opera:option-present :port options) (opera:option-argument :port options) "/opt/candle/")) (format t "Starting server on port ~A~%" port) (candle:server port nil))))) ; vim:ft=lisp