(declare (unit tick-comment)) (module tick-comment () (import scheme) (import (chicken base) (chicken io)) (import commands optimism simple-logger srfi-13) (import tick) (define-command 'comment "\ comment [--comment|-c ] Add a comment to a ticket. If --comment|-c is not provided on the command line, the program will interactively request it. If the argument of --comment|-c is -, the program will read the comment text from stdin." (lambda (args*) (let* ((args (parse-command-line args* `(((--comment -c) . comment)))) (tid (get-opt 'tid args position: 0)) (comment (get-opt '(--comment -c) args))) (unless tid (show-command-help 'comment 1)) (let* ((thash (ensure-ticket tid)) (comment (if comment (if (string=? comment "-") (read-string) comment) (prompt-editor 'comment))) (comment (if (eof-object? comment) "" (string-trim-right comment)))) (set-last-used-ticket-hash! thash) (if (string=? comment "") (log-warning "empty comment - ignored") (begin (write-ticket-change thash (string-append "wrote:\n" comment)) (db-add-change thash "Add new comment"))))))) ) ;; end module