(case subcommand
(:list (job-list (cdr remaining-args)))
(:log (job-log (cdr remaining-args)))
+ (:retry (retry-job (cdr remaining-args)))
(t (format t "~A" (job-usage)))))))
-; (multiple-value-bind (options remaining-args error) (opera:process-arguments (job-options) args)
-; (cond
-; ((eql error :unknown-option) (format *error-output* "Unknown option: ~A. See 'candle job --help'.~%" (car remaining-args)))
-; ((eql error :required-argument-missing) (format *error-output* "Missing argument for ~A. See 'candle job --help'.~%" (car remaining-args)))
-; ((opera:option-present :help options) (format t "~A" (opera:usage "candle job" (job-options) "Lists all jobs in PROJECT if no other action is specified")))
-; ((not (opera:option-present :project-name options)) (format *error-output* "Requires --project argument. See 'candle job --help'.~%" ))
-; ((opera:option-present :log options) (job-log (opera:option-argument :project-name options) (opera:option-argument :log options)))
-; (t (project-history (opera:option-argument :project-name options))))))
(defun job-options ()
'((:name :help :short "h" :long "help" :description "Print this usage.")
"candle job"
(project-options)
"Interacts with projects. The available project subcommands are:
- list List jobs
- log <project>:<sha> View the log for a job"))
+ list List jobs
+ log <project>:<sha> View the log for a job
+ retry <project>:<sha> Retry a job"))
(defun job-list (args)
(let
(format t "~A" (communication:query `(candle:get-job-log ,project-name ,sha)))
(format *error-output* "Job definition ~A is not valid. See 'candle job log --help'.~%" (car remaining-args)))))))
+(defun retry-job (args)
+ (let
+ ((options
+ '((:name :help :short "h" :long "help" :description "Print this usage.")
+ (:positional "<project>:<sha>" :description "<project> is the name of the project, while <sha> is the sha of the job in question."))))
+ (standard-cli "candle job retry" options args :default "<project>:<sha>"
+ (multiple-value-bind (project-name sha) (decompose-job-definition (car remaining-args))
+ (if project-name
+ (progn
+ (communication:query `(candle:retry-job ,project-name ,sha))
+ (format t "Retrying job ~A~%" (car remaining-args)))
+ (format *error-output* "Job definition ~A is not valid. See 'candle job log --help'.~%" (car remaining-args)))))))
+
;;; Section for ./candle run
(defmethod execute-command ((command (eql :run)) args)
(:export
#:server #:add-project #:delete-project #:refresh-project #:list-projects
#:project-branch-information #:run #:*candle-dir* #:*job-system* #:*candle-dir* #:failures
- #:project-job-information #:get-job-log #:job-project #:project-dir #:process-job-in-system))
+ #:project-job-information #:get-job-log #:retry-job #:job-project #:project-dir #:process-job-in-system))
(defpackage #:candle-cli (:use :cl) (:export :run))
(defpackage #:candle-aws (:use :cl))
(find-job-by-project project)
*all-job*))))
-(defun get-job-log (project-name sha)
+(defun find-job-by-project-and-sha (project-name sha)
(let*
((project (find project-name *all-project* :test #'string= :key #'project-name))
(job
:key #'job-sha))))
(when (not project) (error "Project does not exist"))
(when (not job) (error "Job does not exist"))
- (job-log job)))
+ job))
+
+(defun get-job-log (project-name sha)
+ (job-log (find-job-by-project-and-sha project-name sha)))
+
+(defun retry-job (project-name sha)
+ (set-job-status (find-job-by-project-and-sha project-name sha) :queued)
+ (awaken-processor-thread))
(defun list-projects ()
(mapcar