-
-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI for listing available versions of a library #17
Conversation
Doesn't look like the Clojars REST API supports limiting the number of results.
(-> (curl/get (format "https://search.maven.org/solrsearch/select?q=g:%%22%s%%22+AND+a:%%22%s%%22&rows=1" | ||
(-> (curl/get (format "https://search.maven.org/solrsearch/select?q=g:%s+AND+a:%s&rows=1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The %%22
s turn up as double quotes in the Maven search URL. They seem to correspond to searching for "org.clojure"
rather than org.clojure
as group. Both seem to produce identical results.
I'm just going to remove |
The (defn dep-versions [opts]
(let [lib (or (:lib opts)
(first (:cmds opts)))
lib (symbol lib)
git? (or (:sha opts)
(:latest-sha opts))
versions (if git?
::todo
(or (seq (clojars-versions lib opts))
(seq (mvn-versions lib opts))))]
(doseq [v versions]
(println :lib lib :version v)))) |
New solution: look for coordinates on Clojars / Maven. If the coordinates are not found, print error and return with an error code. (defn dep-versions [opts]
(let [lib (or (:lib opts)
(first (:cmds opts)))
lib (symbol lib)
versions (or (seq (clojars-versions lib opts))
(seq (mvn-versions lib opts)))]
(if-not versions
(binding [*out* *err*]
(println "Unable to find" lib "on Clojars or Maven.")
(System/exit 1))
(doseq [v versions]
(println :lib lib :version v))))) |
|
||
dep | ||
|
||
- versions: lists available versions of :lib. Currently suppports Clojars/Maven coordinates, no | ||
Git deps. | ||
|
||
Options: | ||
|
||
:lib - Fully qualified symbol. :lib keyword may be elided when lib name is provided as first option. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied your existing help text structure.
(let [opts (parse-opts opts) | ||
opts (with-default-deps-edn opts)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love how you're working with options. Great fit for Clojure, great fit for Unix CLIs.
@teodorlu Is this PR ready? About: Squash or cleanup git history |
@borkdude If squash & merge is fine - go for it! |
Effort to solve #16.
Ready for review!
Improvement suggestions much welcome.
Design
Example usage:
Make sure listing versions works well by piping into CLI for adding a dependency. The
neil add dep
CLI takes an option map - which works great. We simply produce lines like:lib org.clojure/clojure :version 1.11.0
.neil add dep
currently doesn't support input on stdin, only CLI arguments. To get around this, we can usexargs
.Where fzf can be replaced by any command that selects a single line from stdin and prints that line on stdout.
Option without
xargs
(not implemented, only an idea)If we wanted to avoid the need for xargs, we could support the
-
convention for reading input from stdin:If
neil dep add
can take stdin input, it also makes sense for it to be able to add multiple dependencies, one per line.Remaining work / open questions.
teodor-notes.org
before mergingneil dep add
CLI entrypointprintln
s andpprint
s.