Skip to content

Commit ca3a23c

Browse files
author
Bastien Guerry
committed
src/consolidate-datacodegouvfr.clj: Start using babashka/cli
1 parent 6b548d0 commit ca3a23c

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

src/consolidate-datacodegouvfr.clj

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@
1010
;; - spit latest-tags.json for awesome software
1111

1212
(deps/add-deps '{:deps {clj-rss/clj-rss {:mvn/version "0.4.0"}}})
13+
(deps/add-deps '{:deps {org.babashka/cli {:mvn/version "0.8.60"}}})
1314
(require '[clj-rss.core :as rss]
14-
'[clojure.tools.logging :as log])
15+
'[clojure.tools.logging :as log]
16+
'[babashka.cli :as cli])
17+
18+
;; Define CLI options
19+
(def cli-options
20+
{:test-msg {:desc "Testing options"
21+
:default "This is a default test message"}})
1522

1623
;; Initialize atoms
1724
(def hosts (atom ()))
@@ -266,23 +273,26 @@
266273
(spit "forges.csv" (str n "," kind "\n") :append true))))
267274

268275
;; Main execution
269-
(defn -main []
270-
(fetch-hosts)
271-
(let [annuaire (fetch-annuaire)
272-
annuaire-tops (fetch-annuaire-tops)]
273-
(fetch-owners)
274-
(fetch-repos)
275-
(fetch-public-sector-forges)
276-
(process-owners)
277-
(add-pso-top-id annuaire annuaire-tops)
278-
(output-owners-json)
279-
(output-latest-owners-xml)
280-
(output-repositories-json)
281-
(output-latest-repositories-xml)
282-
(output-forges-csv))
283-
(log/info "Hosts:" (count @hosts))
284-
(log/info "Owners:" (count @owners))
285-
(log/info "Repositories:" (count @repositories))
286-
(log/info "Forges:" (count @forges)))
276+
(defn -main [args]
277+
(let [{:keys [test-msg] :as opts}
278+
(cli/parse-opts args {:spec cli-options})]
279+
(println test-msg)
280+
(fetch-hosts)
281+
(let [annuaire (fetch-annuaire)
282+
annuaire-tops (fetch-annuaire-tops)]
283+
(fetch-owners)
284+
(fetch-repos)
285+
(fetch-public-sector-forges)
286+
(process-owners)
287+
(add-pso-top-id annuaire annuaire-tops)
288+
(output-owners-json)
289+
(output-latest-owners-xml)
290+
(output-repositories-json)
291+
(output-latest-repositories-xml)
292+
(output-forges-csv))
293+
(log/info "Hosts:" (count @hosts))
294+
(log/info "Owners:" (count @owners))
295+
(log/info "Repositories:" (count @repositories))
296+
(log/info "Forges:" (count @forges))))
287297

288-
(-main)
298+
(-main *command-line-args*)

0 commit comments

Comments
 (0)