1 ; Copyright 2022 Frank Duncan (frank@consxy.com) under AGPL3. See distributed LICENSE.txt.
2 (in-package #:candle-server-cli)
5 '((:name :help :short "h" :long "help" :description "Print this usage.")
6 (:name :port :short "p" :long "port" :takes-argument t :variable-name "PORT"
7 :description "Port on which to listen for commands. Defaults to 25004")
8 (:name :dir :long "candle-dir" :takes-argument t :variable-name "DIR"
9 :description "Directory for candle related data. Will be created if does not exist. Defaults to /opt/candle/")
10 (:name :system :long "system" :takes-argument t :variable-name "SYSTEM"
11 :description "System on which to run jobs. Currently available are local and aws. Defaults to local.")))
18 "Starts a candle continuous integration server. Use 'candle' to interact with the server.")))
21 (multiple-value-bind (options remaining-args error) (opera:process-arguments *options* (cdr sb-ext:*posix-argv*))
23 ((opera:option-present :help options) (usage))
25 (format *error-output* "Don't understand ~A. See 'candle-server -h'~%" (car remaining-args))
26 (sb-ext:exit :code 1))
28 (opera:option-present :port options)
29 (not (parse-integer (opera:option-argument :port options) :junk-allowed t)))
30 (format *error-output* "--port requires a number. See 'candle-server -h'~%"))
34 (opera:option-present :port options)
35 (parse-integer (opera:option-argument :port options) :junk-allowed t))
37 (setf candle:*job-system*
38 (if (opera:option-present :system options)
39 (intern (string-upcase (opera:option-argument :system options)) :keyword)
42 ((*error-output* (make-broadcast-stream)))
43 (case candle:*job-system*
44 (:aws (asdf:load-system :candle-aws))
45 (:local (asdf:load-system :candle-local))))
46 (setf candle:*candle-dir*
47 (if (opera:option-present :dir options)
48 (opera:option-argument :dir options)
50 (candle:server port nil))))))