diff options
| author | eltrac <hi@eltr.ac> | 2026-07-05 12:13:45 +0800 |
|---|---|---|
| committer | eltrac <hi@eltr.ac> | 2026-07-05 12:13:45 +0800 |
| commit | 02f1307dd9549f2ba920a6d076cfc9b2278b2a03 (patch) | |
| tree | fd0e479770dcb3cace230a89f0f740b951927214 /vimulti.clj | |
| parent | 9f9786694df463b5b81aad3ff0591042bec6e81b (diff) | |
get repo location from user specified target
Diffstat (limited to 'vimulti.clj')
| -rw-r--r-- | vimulti.clj | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/vimulti.clj b/vimulti.clj index 80c4014..0716f8e 100644 --- a/vimulti.clj +++ b/vimulti.clj @@ -7,7 +7,6 @@ (def default-config {:editor-command "nvim" - :editor-config "/Users/eltrac/.config/nvim/" :default-branch "master"}) ;; configuration helpers @@ -50,31 +49,29 @@ ;; if not alias style (let [separator (if branch-style? #":" (if tag-style? #"@" #" ")) target-array (str/split target separator) - app-name (first target-array) - repo (str #_(TODO))] + app-name (if (= (first target-array) "") "nvim" (first target-array)) + repo (fs/path (System/getProperty "user.home") ".config" app-name)] (when-not (> (count target-array) 2) (println "Invalid target string.") (System/exit 1)) (cond-> {:app-name app-name} branch-style? (assoc :branch (last target-array)) tag-style? (assoc :tag (last target-array)) - ;; TODO add repo location - ))))) + (fs/exists? repo) (assoc :repo repo)))))) ;; main ;; target should be a string like "app-name:branch" or "app-name@tag" (let [[target & args] *command-line-args* target-map (parse-target-string target)] (let [current-branch (or - (get-current-branch (:editor-config config)) + (get-current-branch (:repo target-map)) (:default-branch config))] (when-let [switch-to (or (:branch target-map) (:tag target-map))] (let [tag? (boolean (:tag target-map))] - ;; TODO replace (:editor-config config) with (:repo target-map) - (shell {:dir (:editor-config config)} + (shell {:dir (:repo target-map)} (str "git switch " switch-to (if tag? "--detach" ""))))) (shell {:extra-env {"NVIM_APPNAME" (:app-name target-map)}} (:editor-command config) " " (apply str args)) - (shell {:dir (:editor-config config)} + (shell {:dir (:repo target-map)} (str "git switch " current-branch)))) |
