diff options
author | Christopher Baines <mail@cbaines.net> | 2022-03-13 11:40:49 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2022-03-13 11:40:49 +0000 |
commit | 3a9964701b0520fec1efb2d58c4f5a9891deacd2 (patch) | |
tree | e118cbdb0ba2630cba86851a3d10134752bb6b5b /scripts | |
parent | f69da3686583d53974e720a9e66103126631cb69 (diff) | |
download | nar-herder-3a9964701b0520fec1efb2d58c4f5a9891deacd2.tar nar-herder-3a9964701b0520fec1efb2d58c4f5a9891deacd2.tar.gz |
Support inserting tags when inserting narinfos
This is the beginning of implementing support for tagging.
The communicating of tags through changes still needs implementing.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/nar-herder.in | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/scripts/nar-herder.in b/scripts/nar-herder.in index 1cc5a67..0f4f7f2 100644 --- a/scripts/nar-herder.in +++ b/scripts/nar-herder.in @@ -77,6 +77,20 @@ `((database . ,(string-append (getcwd) "/nar_herder.db")) (database-dump . ,(string-append (getcwd) "/nar_herder_dump.db")))) +(define %import-options + (list (option '("tag") #t #f + (lambda (opt name arg result) + (alist-cons 'tags + (cons (match (string-split arg #\=) + ((key value) + (cons key value))) + (or (assq-ref result 'tags) + '())) + (alist-delete 'tags result)))))) + +(define %import-options-defaults + '()) + (define %server-options (list (option '("port") #t #f (lambda (opt name arg result) @@ -172,8 +186,10 @@ (match (cdr (program-arguments)) (("import" rest ...) - (let* ((opts (parse-options %base-options - %base-option-defaults + (let* ((opts (parse-options (append %base-options + %import-options) + (append %base-option-defaults + %import-options-defaults) rest)) (database (setup-database (assq-ref opts 'database)))) @@ -212,7 +228,9 @@ (lambda (port) ;; Set url to a dummy value as this doesn't ;; matter - (read-narinfo port "https://narherderdummyvalue")))) + (read-narinfo port "https://narherderdummyvalue"))) + #:tags (or (assq-ref opts 'tags) + '())) (report)) narinfos)))))) |