Preserve order in subtask help list.

This commit is contained in:
Phil Hagelberg 2011-11-30 17:42:55 -08:00
parent 1dd8d145db
commit 3dc9ef86c8

View file

@ -30,18 +30,17 @@
(formatted-docstring command docstring padding)))) (formatted-docstring command docstring padding))))
(defn- get-subtasks-and-docstrings-for [task] (defn- get-subtasks-and-docstrings-for [task]
(into {} (map (fn [subtask]
(map (fn [subtask] (let [m (meta subtask)]
(let [m (meta subtask)] [(str (:name m)) (:doc m)]))
[(str (:name m)) (:doc m)])) (:subtasks (meta task))))
(:subtasks (meta task)))))
(defn subtask-help-for (defn subtask-help-for
[task-ns task] [task-ns task]
(let [subtasks (get-subtasks-and-docstrings-for task)] (let [subtasks (get-subtasks-and-docstrings-for task)]
(if (empty? subtasks) (if (empty? subtasks)
nil nil
(let [longest-key-length (apply max (map count (keys subtasks))) (let [longest-key-length (apply max (map (comp count first) subtasks))
help-fn (ns-resolve task-ns 'help)] help-fn (ns-resolve task-ns 'help)]
(string/join "\n" (string/join "\n"
(concat ["\n\nSubtasks available:"] (concat ["\n\nSubtasks available:"]