我想知道如何在我的 opts 中访问默认参数,在它们被 cli args 解析之后。我正在调用我的程序
./rexfer --ifn1 --ifm1 --ofn1 --ofn3
(defn parse-args
"Using the newer cli library, parses command line args."
[args]
(cli args
["-r" "--ifn1" ".csv input file" :default "standfiletrans_acre.csv"]
["-p" "--ifn2" ".csv input file" :default "pp_report_to_change.csv"]
["-m" "--ifm1" ".csv input file" :default "columns.csv"]
["-v" "--ofn1" ".csv output file" :default "re_values.csv"]
["-x" "--ofn2" ".csv output file" :default "re_pp.csv"]
["-u" "--ofn3" ".csv output file" :default "re_mixed_use_ratio.csv"]
["-t" "--rpt" ".csv pipe delimited output file" :default "xfer.csv"]))
(defn -main
[& args]
(let [[opts args banner] (parse-args args)
这是 opts 解析后的输出
{:rpt xfer.csv, :ofn3 re_mixed_use_ratio.csv, :ofn2 re_pp.csv, :ofn1 --ofn3, :ifm1 --ifn1, :ifn2 pp_report_to_change.csv, :ifn1 standfiletrans_acre.csv}
(:ifn1 opts) 返回--ifn1,而不是standfiletrans_acre.csv。