Reputation: 10695
I am moving from [org.clojure/tools.cli "0.1.0"]
to 0.2.2, but am getting
Exception in thread "main" clojure.lang.ArityException:
Wrong number of args (2) passed to: PersistentVector
at the line beginning with (cli args
(defn parse-opts
"Using the newer cli library, parses command line args."
[args]
(cli args
["--ifn1" ".csv input file" :default "benetrak_roster.csv"]
["--ifn2" ".csv input file" :default "billing_roster.csv"]
["--rpt" ".csv pipe delimited output file" :default "bene_gic_rpt.csv"]
["--dump1" "text file report for debug output" :default "dumpfile1.txt"]
["--dump2" "text file report for debug output" :default "dumpfile2.txt"]
["--debug" "Debug flag for logging." :default 0 :parse-fn #(Integer. %)]))
tools.cli is included like this (:use clojure.tools.cli).
I can't see what I'm doing wrong, and would appreciate any pointers or help. Thanks.
By the way, I've tried the following from looking at examples, and it does not work:
(defn -main
[& args]
(let [[opts args banner]
(cli args
["--ifn1" ".csv input file" :default "benetrak_roster.csv"]
["--ifn2" ".csv input file" :default "billing_roster.csv"]
["--rpt" ".csv pipe delimited output file" :default "bene_gic_rpt.csv"]
["--dump1" "text file report for debug output" :default "dumpfile1.txt"]
["--dump2" "text file report for debug output" :default "dumpfile2.txt"]
["--debug" "Debug flag for logging." :default 0 :parse-fn #(Integer. %)])
start-time (str (Date.))]
.
.
.
Upvotes: 1
Views: 123
Reputation: 17773
This seems to work:
(ns test.core
(:use clojure.tools.cli))
(defn parse-opts
"Using the newer cli library, parses command line args."
[args]
(cli args
["--ifn1" ".csv input file" :default "benetrak_roster.csv"]
["--ifn2" ".csv input file" :default "billing_roster.csv"]
["--rpt" ".csv pipe delimited output file" :default "bene_gic_rpt.csv"]
["--dump1" "text file report for debug output" :default "dumpfile1.txt"]
["--dump2" "text file report for debug output" :default "dumpfile2.txt"]
["--debug" "Debug flag for logging." :default 0 :parse-fn #(Integer. %)]))
test.core> (parse-opts [])
[{:debug 0, :dump2 "dumpfile2.txt", :dump1 "dumpfile1.txt", :rpt "bene_gic_rpt.csv", :ifn2 "billing_roster.csv", :ifn1 "benetrak_roster.csv"} [] "Usage:\n\n Switches Default Desc \n -------- ------- ---- \n --ifn1 benetrak_roster.csv .csv input file \n --ifn2 billing_roster.csv .csv input file \n --rpt bene_gic_rpt.csv .csv pipe delimited output file \n --dump1 dumpfile1.txt text file report for debug output \n --dump2 dumpfile2.txt text file report for debug output \n --debug 0 Debug flag for logging. \n"]
test.core>
Are you sure the error isn't in whatever you're passing to parse-opts
?
Also: are you sure you've got the right version (and ONLY the right version) of tools.cli in your project.clj?
Upvotes: 1