mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 05:18:07 -05:00
etc: teams: Refactor list-teams.
* etc/teams.scm.in (print-team, sort-teams): New procedures. (list-teams): Use them.
This commit is contained in:
parent
c0dad02e9f
commit
ee4a429d49
1 changed files with 30 additions and 26 deletions
|
@ -672,37 +672,41 @@ (define* (list-members team #:key (prefix ""))
|
|||
(format #t "~a~a~%" prefix (member->string member)))
|
||||
(sort-members (team-members team))))
|
||||
|
||||
(define (list-teams)
|
||||
"Print all teams, their scope and their members."
|
||||
(define port* (current-output-port))
|
||||
(define width* (%text-width))
|
||||
(for-each
|
||||
(lambda (team)
|
||||
(format port*
|
||||
"\
|
||||
(define (print-team team)
|
||||
"Print TEAM, a <team> record object."
|
||||
(format #t
|
||||
"\
|
||||
id: ~a
|
||||
name: ~a
|
||||
description: ~a
|
||||
~amembers:
|
||||
"
|
||||
(team-id team)
|
||||
(team-name team)
|
||||
(or (and=> (team-description team)
|
||||
(lambda (text)
|
||||
(string->recutils
|
||||
(fill-paragraph text width*
|
||||
(string-length "description: ")))))
|
||||
"<none>")
|
||||
(match (team-scope team)
|
||||
(() "")
|
||||
(scope (format #f "scope: ~{~s ~}~%" scope))))
|
||||
(list-members team #:prefix "+ ")
|
||||
(newline))
|
||||
(sort
|
||||
(hash-map->list (lambda (key value) value) %teams)
|
||||
(lambda (team1 team2)
|
||||
(string<? (symbol->string (team-id team1))
|
||||
(symbol->string (team-id team2)))))))
|
||||
(team-id team)
|
||||
(team-name team)
|
||||
(or (and=> (team-description team)
|
||||
(lambda (text)
|
||||
(string->recutils
|
||||
(fill-paragraph text (%text-width)
|
||||
(string-length "description: ")))))
|
||||
"<none>")
|
||||
(match (team-scope team)
|
||||
(() "")
|
||||
(scope (format #f "scope: ~{~s ~}~%" scope))))
|
||||
(list-members team #:prefix "+ ")
|
||||
(newline)))
|
||||
|
||||
(define (sort-teams teams)
|
||||
"Sort TEAMS, a list of <team> record objects."
|
||||
(sort teams
|
||||
(lambda (team1 team2)
|
||||
(string<? (symbol->string (team-id team1))
|
||||
(symbol->string (team-id team2))))))
|
||||
|
||||
(define* (list-teams)
|
||||
"Print all teams, their scope and their members."
|
||||
(for-each print-team
|
||||
(sort-teams (hash-map->list
|
||||
(lambda (_ value) value) %teams))))
|
||||
|
||||
|
||||
(define (diff-revisions rev-start rev-end)
|
||||
|
|
Loading…
Reference in a new issue