2012-08-27 97 views
1

我從[org.clojure/tools.cli "0.1.0"]移動到0.2.2,但我越來越爲什麼編譯tools.cli會導致向量參數錯誤?

Exception in thread "main" clojure.lang.ArityException: 
Wrong number of args (2) passed to: PersistentVector 

在符合(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開始包括像這樣(:使用clojure.tools.cli )。

我看不到我做錯了什麼,並會感謝任何指針或幫助。謝謝。

順便說一句,我試着從看例子以下,和它不工作:

(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.))] 
     . 
     . 
     . 

回答

1

這似乎工作:

(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> 

確定錯誤ISN不管你傳遞給parse-opts

另外:你確定你的project.clj中有tools.cli的正確版本(並且只有正確的版本)?

+0

妙不可言。一個依賴模塊不必要地引入舊版本的tools.cli。謝謝。 – octopusgrabbus

相關問題