Skip to content

Commit 14bd1b8

Browse files
author
Bastien Guerry
committed
feat(codegouvfr-output-data): Use -f to limit to a host/forge
1 parent 534512b commit 14bd1b8

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/codegouvfr-output-data.clj

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
;;; Define CLI options
1919

2020
(def cli-options
21-
{:help {:alias :h
22-
:desc "Display this help message"}
23-
:test {:alias :t
24-
:desc "Test with a limited number of hosts (2 by default)"}})
21+
{:help {:alias :h
22+
:desc "Display this help message"}
23+
:test {:alias :t
24+
:desc "Test with a limited number of hosts (2 by default)"}
25+
:forge {:alias :f
26+
:desc "Limit to a specific forge (e.g., 'github.com')"}})
2527

2628
(defn- show-help
2729
[]
@@ -334,10 +336,18 @@
334336
(defn- set-hosts! []
335337
(when-let [res (fetch-json (:hosts urls))]
336338
(reset! hosts
337-
(if-let [test-opt (:test @cli-opts)]
338-
(take (if (int? test-opt) test-opt 2)
339+
(cond
340+
;; Filter by specific host if host option is provided
341+
(:host @cli-opts)
342+
(filter #(= (if (= (:name %) "GitHub") "github.com" (:name %))
343+
(:host @cli-opts))
344+
res)
345+
;; Use test option if provided
346+
(:test @cli-opts)
347+
(take (if (int? (:test @cli-opts)) (:test @cli-opts) 2)
339348
(shuffle res))
340-
res))))
349+
;; Otherwise use all hosts
350+
:else res))))
341351

342352
(defn- update-owners! []
343353
(doseq [[f forge-data] @forges]
@@ -718,9 +728,9 @@ This list is published under Licence Ouverte 2.0 and CC BY.")
718728
(defn- display-data! []
719729
(log/info "Hosts:" (count @hosts))
720730
(log/info "Owners:" (count @owners))
721-
(log/info "Owners (limited):" (count (owners-as-map @owners)))
731+
(log/info "Owners (expurged):" (count (owners-as-map @owners)))
722732
(log/info "Repositories:" (count @repositories))
723-
(log/info "Repositories (limited):" (count (repositories-as-map @repositories)))
733+
(log/info "Repositories (expurged):" (count (repositories-as-map @repositories)))
724734
(when-not (:test @cli-opts)
725735
(log/info "Awesome codegouvfr:" (count @awesome))))
726736

0 commit comments

Comments
 (0)