I'm working my way through one of my first Clojure programs. The one thing I have left to do is have my program accept command line arguments. The number of args can vary (but needs to be at least one), and then each command line arg needs to be provided as an argument to a function in my main
, one at a time. I've been reading online and it seems that clojure/tools.cli
is the way to do it, (using parse-opts
maybe?). But I can't figure it out for the life of me. There's no validation, really that needs to happen -- whatever the user would provide would be valid. (The only thing that needs to be checked is that there is at least one argument provided). Any suggestions on how to go about this?
All the examples I run into seem very complicated and go over my head very easily.
An easy example of what I'm trying to do is after a user provides any number of command line arguments, then have clojure print each string in a new line of the terminal.
I use leiningen to run my programs.
clojure.tools.cli/parse-opts
-- ie. what code you have, what behavior you want, what behavior you're actually getting instead? (See the minimal reproducible example page in the Help Center for guidance on putting together the shortest possible code sample that lets someone else see your problem for themselves). – Astigmatic