diff options
Diffstat (limited to 'vimulti.clj')
| -rw-r--r-- | vimulti.clj | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/vimulti.clj b/vimulti.clj index 30c6c25..4775f11 100644 --- a/vimulti.clj +++ b/vimulti.clj @@ -6,8 +6,7 @@ '[clojure.string :as str]) (def default-config - {:editor-command "nvim" - :default-branch "master"}) + {:editor-command "nvim"}) ;; configuration helpers (defn- config-path [] @@ -52,7 +51,7 @@ app-name (if (= (first target-array) "") "nvim" (first target-array)) repo (fs/path (System/getProperty "user.home") ".config" app-name) no-mark (= (count target-array) 1)] - (when (> (count target-array) 2) + (when (> (count target-array) 2) (println "Invalid target string.") (System/exit 1)) (cond-> {:app-name app-name} @@ -63,16 +62,14 @@ ;; 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 (:repo target-map)) - (:default-branch config))] - (when-let [switch-to (or (:branch target-map) - (:tag target-map))] - (let [tag? (boolean (:tag target-map))] - (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 (:repo target-map)} - (str "git switch " current-branch)))) + target-map (parse-target-string target) + current-branch (get-current-branch (:repo target-map))] + (when-let [switch-to (or (:branch target-map) + (:tag target-map))] + (let [tag? (boolean (:tag target-map))] + (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 (:repo target-map)} + (str "git switch " current-branch))) |
