<commit_before>(ns dependable.cli
  (:require [dependable.util :refer :all]
            [clojure.java.io :as io])
  (:gen-class))

(def cli-options
  ;; An option with a required argument
  [["-c" "--config-file FILE" "Configuration file"
    :default "./dependable.edn"
    :validate [
               #(.exists (io/as-file))
               "Must be a regular file (which hopefully contains project info."]]
   ;; A boolean option defaulting to nil
   ["-h" "--help"]])

(defn -main [& args]
  (parse-opts args cli-options))

(:require [clojure.tools.cli :refer [parse-opts]])



(defn -main [& args]
  (println "I am a robot."))<commit_msg>CLI appears to work, basically<commit_after>(ns dependable.cli
  (:require [dependable.util :refer :all]
            [clojure.tools.cli :refer [parse-opts]]
            [clojure.java.io :as io]
            [clojure.string :as string]
            [clojure.edn :as edn])
  (:gen-class))

(def cli-options
  [["-p" "--project-file FILE" "Project spec file"
    :default "./dependable.edn"
    :validate [
               #(.exists (io/as-file %))
               "Must be a regular file (which hopefully contains project info."]]])

(defn update-repo! [project-config options arguments]
  (println "goodbye"))

(def subcommand-cli
  {"update-repo"
   {:function update-repo!
    :cli [

          ]}})

(defn command-list [commands]
  (->> ["Commands are:"
        ""
        (string/join \newline (map #(str "  - " %) commands))
        ]
       (string/join \newline)))

(defn usage [options-summary & {:keys [sub-command]}]
  (let [display-command (if sub-command
                          sub-command
                          "<command>")]
    (->> [(str "Usage: dependable <options> "
               display-command
               " <"
               display-command
               "-options>")
          ""
          "Options are:"
          ""
          options-summary
          ]
         (string/join \newline))))

(defn error-msg [errors & {:keys [sub-command]}]
  (str "The following errors occurred while parsing commandline options"
       (if sub-command
         (str " for subcommand `" sub-command "`")
         "")
       ":\n\n"
       (string/join \newline (map #(str "  - " errors)))))

(defn exit [status msg]
  (.println *err* msg)
  (System/exit status))

(defn -main [& args]
  (let [{:keys [options arguments errors summary]}
        (parse-opts args (concat
                          cli-options
                          [["-h" "--help"]])
                    :in-order true)]
    (cond
      (:help options) (exit 0 (str (usage summary)
                                   "\n\n"
                                   (command-list (keys subcommand-cli))))
      errors (exit 1 (usage summary
                            "\n"
                            (command-list (keys subcommand-cli)))))
    (let [global-options options
          subcommand (first arguments)
          subcmd-cli (get subcommand-cli subcommand)]
      (when (nil? subcmd-cli)
        (exit 1 (error-msg (str "Unknown command: " subcommand))))
      (let [{:keys [options arguments errors summary]}
            (parse-opts args (concat
                              (:cli subcmd-cli)
                              [["-h" "--help"]]))]
        (cond
          (:help options) (exit 0 (usage summary :sub-command subcommand))
          errors (exit 1 (usage summary :sub-command subcommand)))
        ((:function subcmd-cli)
         (edn/read-string (slurp (:project-file global-options)))
         options arguments)))))
{'fraction_non_alphanumeric': 0.1470753655793026, 'fraction_numerical': 0.00140607424071991, 'mean_word_length': 1.7702492211838006, 'pattern_counts': {'":': 1, '<': 6, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5073434', 'n_tokens_mistral': 1065, 'n_tokens_neox': 1043, 'n_words': 287}