diff options
-rwxr-xr-x | bin/tissue | 25 | ||||
-rw-r--r-- | tissue/issue.scm | 25 |
2 files changed, 35 insertions, 15 deletions
@@ -402,18 +402,19 @@ To get usage information for one of these sub-commands, run (current-error-port)) (newline (current-error-port)) (exit #f))) - (apply (match command - ("news" tissue-news) - ("list" tissue-list) - ("edit" tissue-edit) - ("show" tissue-show) - ("web" tissue-web) - (invalid-command - (format (current-error-port) "Invalid command `~a'~%~%" - invalid-command) - (print-usage) - (exit #f))) - args))) + (parameterize ((%aliases (tissue-configuration-aliases (load-config)))) + (apply (match command + ("news" tissue-news) + ("list" tissue-list) + ("edit" tissue-edit) + ("show" tissue-show) + ("web" tissue-web) + (invalid-command + (format (current-error-port) "Invalid command `~a'~%~%" + invalid-command) + (print-usage) + (exit #f))) + args)))) ;; tissue is an alias for `tissue list' ((_) (tissue-list)))) diff --git a/tissue/issue.scm b/tissue/issue.scm index 00fcbcf..8d1d11c 100644 --- a/tissue/issue.scm +++ b/tissue/issue.scm @@ -28,7 +28,8 @@ #:use-module (ice-9 match) #:use-module (ice-9 regex) #:use-module (tissue utils) - #:export (issue + #:export (%aliases + issue issue-file issue-title issue-creator @@ -49,6 +50,9 @@ post-relative-date issues)) +(define %aliases + (make-parameter #f)) + (define-record-type <issue> (issue file title creator created-date created-relative-date last-updater last-updated-date last-updated-relative-date @@ -128,6 +132,18 @@ return #f." (time-monotonic->date (make-time time-monotonic 0 timestamp))) +(define (resolve-alias name aliases) + "Resolve NAME against ALIASES, a list of aliases. ALIASES should be +in the form of the argument of the same name to `tissue-configuration' +in (tissue tissue). If no alias is found, NAME is returned as such." + (cond + ((find (cut member name <>) + aliases) + => (match-lambda + ((canonical-name _ ...) canonical-name) + (() name))) + (else name))) + (define (file-details file) "Return a hashtable of details extracted from gemini FILE." (let ((result (make-eq-hashtable))) @@ -162,7 +178,9 @@ return #f." ;; their keys. (for-each (match-lambda (((or 'assign 'assigned) . values) - (hashtable-append! result 'assigned values)) + (hashtable-append! result 'assigned + (map (cut resolve-alias <> (%aliases)) + values))) (((or 'keywords 'severity 'status 'priority 'tags 'type) . values) (hashtable-append! result 'keywords values)) (_ #t)) @@ -205,7 +223,8 @@ return #f." (tmap (match-lambda ((index . line) (let* ((alist (call-with-input-string line read)) - (author (assq-ref alist 'author)) + (author (resolve-alias (assq-ref alist 'author) + (%aliases))) (date (assq-ref alist 'author-date)) (relative-date (assq-ref alist 'author-relative-date))) (when (zero? index) |