Support fully qualified Symbol for clojure.main -m

Description

Given the new tools.deps CLI capabilities it would be very convenient to have a clojure.main -m option that optionally allows calling specific function, not just -main.

Creating utilities for use with the clojure tool otherwise requires creating a new namespace for each "task" (or resorting to -e or script.clj files).

Leiningen supports the lein run -m some.util/task ... notation. shadow-cljs does as well.

Environment

None

Activity

Show:
Alex Miller
January 25, 2018, 4:25 PM

I think it would be better to instead add a new flag that supports this (-f or something) rather than push new functionality onto -m.

Mike Fikes
February 2, 2018, 1:04 PM

An alternative to consider: Imitate the existing facility in ClojureScript, which has a main-cli-fn:

As an example use, with foo.cljs:

Then

One place where this can really be advantageous over -m or even a -f approach is if you make a shebang script and you want to have command-line arguments passed, it would be nice to start that script simply with

and then let the main-cli-fn mechanism ensure command-line-args is routed to that function, without having to put -f some-qualified/function in the shebang line where on Linux not possible to specify interpreter arguments in the shebang line.

Alex Miller
February 2, 2018, 1:20 PM

Bleh, that sounds gross. I have some new aliasing stuff in clj that will help some of this in work.

Thomas Heller
February 4, 2018, 11:14 PM

Patch implements the suggested -f argument rather than changing the existing -m.

Assignee

Unassigned

Reporter

Thomas Heller

Labels

Approval

Triaged

Patch

None

Priority

Minor