mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-30 19:03:01 +01:00
Allow updating khoj content index from within khoj.el
- Split transient config menu by type
This commit is contained in:
parent
a8d0c7d905
commit
9d64a009fd
1 changed files with 18 additions and 3 deletions
|
@ -373,13 +373,28 @@ Render results in BUFFER-NAME."
|
||||||
;; trigger incremental search
|
;; trigger incremental search
|
||||||
(call-interactively #'khoj-incremental)))
|
(call-interactively #'khoj-incremental)))
|
||||||
|
|
||||||
|
(transient-define-suffix khoj--update (&optional args)
|
||||||
|
(interactive (list (transient-args transient-current-command)))
|
||||||
|
(let* ((force-update (if (member "--force-update" args) "true" "false"))
|
||||||
|
(content-type (or (transient-arg-value "--content-type=" args) (khoj--buffer-name-to-content-type (buffer-name))))
|
||||||
|
(config-url (format "%s/api/update?t=%s&force=%s" khoj-server-url content-type force-update))
|
||||||
|
(url-request-method "GET"))
|
||||||
|
;; Call khoj API to update content type
|
||||||
|
(url-retrieve
|
||||||
|
config-url
|
||||||
|
(lambda (_) (message "Khoj %s index %supdated!" content-type (if (member "--force-update" args) "force " ""))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(transient-define-prefix khoj ()
|
(transient-define-prefix khoj ()
|
||||||
[["Set"
|
[["Set"
|
||||||
("t" "Content Type" khoj--content-type-switch)
|
("t" "Content Type" khoj--content-type-switch)]
|
||||||
("n" "Results Count" "--results-count=" :init-value (lambda (obj) (oset obj value (format "%s" khoj-results-count))))]]
|
["Set Search"
|
||||||
[["Act" ("s" "Search" khoj--search)]])
|
("n" "Results Count" "--results-count=" :init-value (lambda (obj) (oset obj value (format "%s" khoj-results-count))))]
|
||||||
|
["Set Update"
|
||||||
|
("-f" "Force Update" "--force-update")]]
|
||||||
|
[["Act"
|
||||||
|
("s" "Search" khoj--search)
|
||||||
|
("u" "Update" khoj--update)]])
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun khoj-simple (query)
|
(defun khoj-simple (query)
|
||||||
|
|
Loading…
Reference in a new issue