我正在使用多种方法来解析命令行命令及其参数。
(defmulti run (fn [command args] command))
(defmethod run :default
[& _]
...)
^{:args "[command]"}
(defmethod run "help"
[_ & [args]]
"Display command list or help for a given command"
...)
^{:args ""}
(defmethod run "version"
[_ & [args]]
"Print program's version"
...)
(defn -main
[& args]
(run (first args)
(next args)))
当我尝试访问元数据时,对于特定方法,clojure 返回nil
:
(meta ((methods run) "help"))