From ec73dd0c1adb3ff7f111a98984121a18b5cb2be5 Mon Sep 17 00:00:00 2001 From: Felisp Date: Tue, 13 Aug 2024 02:56:20 +0200 Subject: [PATCH] Added CLI parsing template --- project.clj | 2 +- src/rss_thread_watch/core.clj | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/project.clj b/project.clj index db93458..3345fd6 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject rss-thread-watch "0.3.5-SNAPSHOT" +(defproject rss-thread-watch "0.3.7-SNAPSHOT" :description "RSS based thread watcher" :url "http://example.com/FIXME" :license {:name "AGPL-3.0-only" diff --git a/src/rss_thread_watch/core.clj b/src/rss_thread_watch/core.clj index bd47155..6802b1f 100644 --- a/src/rss_thread_watch/core.clj +++ b/src/rss_thread_watch/core.clj @@ -15,6 +15,7 @@ (ns rss-thread-watch.core (:require [clojure.java.io :as io] [clojure.edn :as edn] + [clojure.tools.cli :refer [parse-opts]] [ring.adapter.jetty :as jetty] [ring.middleware.params :as rp] [rss-thread-watch.watcher :as watcher] @@ -22,6 +23,8 @@ [rss-thread-watch.utils :as u]) (:gen-class)) +(def VERSION "0.3.7") + ;; Internal default config (def CONFIG-DEFAULT "Internal default config" @@ -37,8 +40,19 @@ :boards-enabled {"/mlp/" {} "/g/" {}}}) +(def cli-options + "Configuration defining program arguments for cli.tools" + [["-v" "--version" "Print version and license information"] + ["-h" "--help" "Prints help"] + ["-c" "--config CONFIG_FILE" "Specify config file to use for this run" + :default "./config.edn" + :validate [#(u/file-exists? %) "Specified config file does not exist or is not readable"]] + [nil "--print-default-config" "Prints internal default config file to STDOUT and exits"]]) + +;; Todo: Think of a way to start repeated download for every catalog efficiently (defn set-interval "Calls function every ms" + ^{:deprecated true} [callback ms] (future (while true (do (try (callback)