diff options
author | Christopher Baines <mail@cbaines.net> | 2019-12-10 08:28:38 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2019-12-12 20:07:22 +0000 |
commit | c90f411e5e0098b012918e876f04949ae2ff3948 (patch) | |
tree | 40d87a07387c22b48181ceece62ea7b53b2afb43 /scripts | |
parent | f13077d0873ebcd58477a7721167378a1b1d9920 (diff) | |
download | data-service-c90f411e5e0098b012918e876f04949ae2ff3948.tar data-service-c90f411e5e0098b012918e876f04949ae2ff3948.tar.gz |
Add options to the query-build-servers script
So you can select to query specific build servers.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/guix-data-service-query-build-servers.in | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/scripts/guix-data-service-query-build-servers.in b/scripts/guix-data-service-query-build-servers.in index aa66a9f..9ef8347 100644 --- a/scripts/guix-data-service-query-build-servers.in +++ b/scripts/guix-data-service-query-build-servers.in @@ -26,7 +26,39 @@ (guix-data-service database) (guix-data-service builds)) -(with-postgresql-connection - "query-build-servers" - (lambda (conn) - (query-build-servers conn (cdr (command-line))))) +(define %options + ;; Specifications of the command-line options + (list (option '("build-server-id") #t #f + (lambda (opt name arg result) + (alist-cons + 'build-server-ids + (cons (string->number arg) + (or (assoc-ref result 'build-server-ids) + '())) + (alist-delete 'build-server-ids result)))))) + +(define %default-options + ;; Alist of default option values + '()) + +(define (parse-options args) + (args-fold + args %options + (lambda (opt name arg result) + (error "unrecognized option" name)) + (lambda (arg result) + (alist-cons + 'revision-commits + (cons arg + (or (assoc-ref result 'revision-commits) + '())) + (alist-delete 'revision-commits result))) + %default-options)) + +(let ((opts (parse-options (cdr (program-arguments))))) + (with-postgresql-connection + "query-build-servers" + (lambda (conn) + (query-build-servers conn + (assq-ref opts 'build-server-ids) + (assq-ref opts 'revision-commits))))) |