- (:name :project-name :long "project" :takes-argument t
- :variable-name "PROJECT"
- :description "The project name for the jobs under consideration. Required argumnet.")
- (:name :log :long "log" :takes-argument t
- :variable-name "SHA"
- :description "Show's the processing log for job at sha SHA. SHA can be truncated.")))
-
-(defun project-history (name)
- (format t "~{~A~%~}"
- (mapcar
- #'job-info->line
- (sort (communication:query `(candle:project-job-information ,name)) #'< :key #'third))))
+ (:positional "<subcommand>" :description "Job subcommand, see below.")))
+
+(defun job-usage ()
+ (opera: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
+ retry <project>:<sha> Retry a job"))
+
+(defun job-list (args)
+ (let
+ ((options
+ '((:name :help :short "h" :long "help" :description "Print this usage.")
+ (:name :project :long "project" :variable-name "PROJECT" :takes-argument t :description "Restrict jobs to project named by PROJECT"))))
+ (standard-cli "candle job list" options args :default nil
+ (format t "~{~A~%~}"
+ (mapcar
+ #'job-info->line
+ (sort (communication:query `(candle:project-job-information ,(opera:option-argument :project parsed-options))) #'< :key #'fourth))))))
+
+(defun decompose-job-definition (job-definition)
+ (let
+ ((pos (position #\: job-definition)))
+ (when
+ pos
+ (values
+ (subseq job-definition 0 pos)
+ (subseq job-definition (1+ pos))))))
+
+(defun job-log (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 log" options args :default "<project>:<sha>"
+ (multiple-value-bind (project-name sha) (decompose-job-definition (car remaining-args))
+ (if project-name
+ (format t "~A" (communication:query `(candle:get-job-log ,project-name ,sha)))
+ (error-and-exit "Job definition ~A is not valid. See 'candle job log --help'.~%" (car remaining-args)))))))