Skip to content

Conversation

athos
Copy link
Owner

@athos athos commented Aug 24, 2021

Currently, there is no way to pass command-line args to the -main function when -m is specified.
This PR provides the way to do that:

$ cat src/arith.clj
(ns arith)

(defn -main [op & args]
  (if-let [op' (case op "add" + "sub" - nil)]
    (let [args' (map read-string args)]
      (prn (apply op' args')))
    (throw (ex-info (str "Unknown op: " op) {}))))
$ trench -m arith add 1 2
3
$ trench -m arith sub 3 1
2
$

Also, -- can be used as a separator to distinguish arguments to pass to -main from the ones that should be passed directly to Trenchman:

$ trench -m arith -- add 1 2

@athos athos merged commit 53bc550 into main Aug 24, 2021
@athos athos deleted the feature/main-args branch August 24, 2021 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant