Skip to content

Commit

Permalink
0.0.8 - remove exit function
Browse files Browse the repository at this point in the history
  • Loading branch information
somecho committed Jul 2, 2023
1 parent 9273f07 commit 73c196d
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.lsp
.nrepl-port
target
.env
27 changes: 27 additions & 0 deletions build.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
(ns build
(:require [clojure.tools.build.api :as b]
[deps-deploy.deps-deploy :as dd]))

(def lib 'org.clojars.some/depo)
(def version "0.0.8")
(def jar-file (format "target/%s-%s.jar" (name lib) version))
(def class-dir "target/classes")

(defn clean [_]
(b/delete {:path "target"}))

(defn jar [_]
(b/write-pom {:class-dir class-dir
:lib lib
:version version
:basis (b/create-basis {:project "deps.edn"})
:src-dirs ["src"]})
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(b/jar {:class-dir "target/classes"
:jar-file jar-file}))

(defn deploy [_]
(dd/deploy {:installer :remote
:artifact jar-file
:pom-file (b/pom-path {:lib lib :class-dir class-dir})}))
20 changes: 15 additions & 5 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{:paths ["src"],
:deps {rewrite-clj/rewrite-clj {:mvn/version "1.1.47"},
cli-matic/cli-matic {:mvn/version "0.5.4"},
clj-http/clj-http {:mvn/version "3.12.3"},
metosin/malli {:mvn/version "0.11.0"},
zprint/zprint {:mvn/version "1.2.7"}}}
:deps
{rewrite-clj/rewrite-clj {:mvn/version "1.1.47"},
cli-matic/cli-matic {:mvn/version "0.5.4"},
clj-http/clj-http {:mvn/version "3.12.3"},
metosin/malli {:mvn/version "0.11.0"},
zprint/zprint {:mvn/version "1.2.7"}}
:aliases
{:build {:extra-deps {io.github.clojure/tools.build {:mvn/version "0.9.4"}
slipset/deps-deploy {:mvn/version "RELEASE"}}
:ns-default build}
:deploy {:extra-deps {slipset/deps-deploy {:mvn/version "0.2.1"}}
:exec-fn deps-deploy.deps-deploy/deploy
:exec-args {:installer :remote
:sign-releases? false
:artifact "target/depo-0.0.7.jar"}}}}
5 changes: 0 additions & 5 deletions project.clj

This file was deleted.

7 changes: 4 additions & 3 deletions src/depo/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
(let [args _arguments
config-path (if file file (rw/get-config))]
(if-not (empty? args)
(mapv #(rw/write-dependency config-path %) args)
(e/exit {:msg (:no-args e/errors) :code 1}))))
(do (mapv #(rw/write-dependency config-path %) args)
(println "Done!"))
(println (e/err :no-args)))))

(def add-cmd {:command "add"
:description "adds dependencies to a Clojure project."
Expand All @@ -17,7 +18,7 @@
(def CONFIGURATION
{:command "depo"
:description "manage Clojure dependencies easily"
:version "0.0.6"
:version "0.0.8"
:opts [{:as "path to configuration file"
:default nil
:option "file"
Expand Down
13 changes: 6 additions & 7 deletions src/depo/errors.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
:invalid-version "The version is malformed"
:version-not-exist "The version does not exist"})

(defn err [error-key & opts]
(defn err
"Given a key identifying the type of error, returns a string
containing the error message."
[error-key & opts]
(let [opts (first opts)]
(case error-key
:no-args
"Requires atleast one argument"
:invalid-argument
(str "The argument " (:argument opts) " is invalid")
:version-not-exist
(str (:artifactID opts) " version " (:version opts) " does not exist"))))

(defn exit
"Exits the program with the given code and prints a message if any."
[{:keys [msg code]}]
(when msg (println msg))
(System/exit code))

0 comments on commit 73c196d

Please sign in to comment.