Skip to content

Commit 57ba5fa

Browse files
committed
Add the config paths to the db stats command
1 parent c363e80 commit 57ba5fa

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/clojure_skills/cli.clj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,15 @@
409409
(let [[config db] (load-config-and-db)
410410
stats (search/get-stats db)
411411
db-path (config/get-db-path config)
412+
config-file-path (config/get-config-file-path)
413+
project-config-path (config/get-project-config-file-path)
412414
permissions (get config :permissions {})
413415
format (output/get-output-format json human config)]
414416
(output/output
415417
{:type :stats
416418
:configuration {:database-path db-path
419+
:config-file-path config-file-path
420+
:project-config-path project-config-path
417421
:auto-migrate (get-in config [:database :auto-migrate] true)
418422
:skills-directory (get-in config [:project :skills-dir] "skills")
419423
:prompts-directory (get-in config [:project :prompts-dir] "prompts")

src/clojure_skills/output.clj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@
261261
(println (bling/bling [:bold "Database Statistics"]))
262262
(println)
263263
(println (bling/bling [:underline "Configuration:"]))
264+
(println (str " Global config: " (:config-file-path config)))
265+
(when (:project-config-path config)
266+
(println (str " Project config: " (:project-config-path config))))
264267
(println (str " Database: " (:database-path config)))
265268
(println (str " Skills directory: " (:skills-directory config)))
266269
(println (str " Prompts directory: " (:prompts-directory config)))

test/clojure_skills/cli_db_test.clj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,19 @@
173173
(let [count (jdbc/execute-one! tu/*connection*
174174
["SELECT COUNT(*) as count FROM skills"])]
175175
(is (= 0 (:count count))))))))
176+
177+
(deftest db-stats-config-paths-test
178+
(testing "Given: A database with configuration"
179+
(binding [cli/*exit-fn* mock-exit]
180+
(with-redefs [cli/load-config-and-db mock-load-config-and-db]
181+
(testing "When: We request database statistics"
182+
(let [{:keys [output]} (capture-output #(cli/cmd-stats {}))
183+
parsed (tu/parse-json-output output)
184+
config (:configuration parsed)]
185+
(testing "Then: Configuration should include config file paths"
186+
(is (contains? config :config-file-path) "config-file-path is present")
187+
(is (string? (:config-file-path config)) "config-file-path is a string")
188+
(is (contains? config :project-config-path) "project-config-path is present")
189+
(is (string? (:project-config-path config)) "project-config-path is a string")
190+
(is (contains? config :database-path) "database-path is present")
191+
(is (string? (:database-path config)) "database-path is a string"))))))))

0 commit comments

Comments
 (0)