I would like to search and install clojure dependencies from the commandline.
Does there exists a tool/leiningen command/lein change
script?/... that can:
project.clj
to include the dependency (latest version)Much along the lines of npm install --save
(--save-dev
) and npm search
, for those that are familiar with npm (JS/Node package manager).
(Maybe boot provides a more npm-like workflow?)
You could find complete list of all Leiningen plugins at its Plugins Wiki page.
I just looked through Development Tools section and found two plugins that may interest you:
And here is an example of adding new dependencies with lein-plz
(from its Readme):
$ lein plz add core.async cljs data.json
And an example of updating outdated dependencies with lein-ancient
(from its Readme):
$ lein ancient upgrade-profiles [<options>]
OK, based on clarifications in the comment, I would suggest looking at some of the clojure linters. While most focus on your project code tree, some will also examine your project.clj file. There is no one tool I can think off, but there are a number of separate tools which can help with little parts of what your after. You can use lein tasks and aliases to automate some of the process and if your using emacs, there are some add ons that will help a bit.
Eastwood: This one has a milestone to add functionality which will examine the :dependencies section in your project.clj and identify dependencies which are not being used. While not implemented yet, it is worth keeping an eye on and I think it is a useful plugin (written by the author of lein btw)
slamhound: This plugin will examine your namespace declarations and clean them up so that they only contain things which are required. A prerequisite for any tool which might be able to re-write your project.clj file IMO
kibit and bikeshed: these two will look for possible cleanup and code improvements to help keep your code consistent and more idomatic
Many of these types of tools can be useful, but their effectiveness can be limited by the 'quality' of your clojure code base. I find you get better results with such tools if your code is as consistent and idiomatic as possible. Running bikeshed -> kibit -> slamhound -> eastwood seems to provide good functionality for me.
If your using emacs, you might also find clj-refactor.el useful. Also note that lein does have a search facility - it can be slow if the indexes need to be updated, but after that is quite fast. However, it isn't that functional as a general search facility, but if your just looking to find the library name and version so that you can add them to your dependencies, it can be pretty useful - in the case when I'm looking for a library to solve a problem (as opposed to a specific known library when I just need to get the name and version number) I tend to just use google and some of the sites out there which collect info on available libs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With