This is fully(?) supported by Leiningen, sort of. In short:
$ (lein update-in :version pr -- version ; lein update-in :name pr -- version) | cut -d '"' -f 2
This works by abusing the update-in
command to apply clojure.core/pr
to the :version
or :name
project key. (You can see all project keys by using just a colon as the member to pr. The just-a-colon feature is described by lein help update-in
.)
Leiningen requires an actual command too, in addition to update-in
. Because pr
returns nil, I suppose the updates damage the project map and make it unsuitable for real work. The above demo sidesteps the problem by using the version
command to print Leiningen's own version.
Oddly, the printed version or name appears more than once; thus the cut
command to take only the first quoted string on each line. We assume you haven't used quotes in your project name or version!
You can stack update-in
's on one command line, but doing so makes the name and version harder to parse from the output.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…