diff --git a/dust b/dust index ffced9b..297c76d 100755 --- a/dust +++ b/dust @@ -6,10 +6,20 @@ if [ -L "$base_path" ]; then fi base_path=`dirname $base_path` -pixie_path=`which pixie-vm` +pixie_path=`which pixie` if [ -z "$pixie_path" ]; then - echo "Error: 'pixie-vm' must be on your PATH" - exit 1 + pixie_path=`which pixie-vm` + if [ -z "$pixie_path" ]; then + pixie_path=`which pxi` + if [ -z "$pixie_path" ]; then + echo "Error: 'pixie' must be on your PATH" + exit 1 + #else + # echo "Warning: Using 'pxi' on path is deprecated. 'pixie' is preferred." + fi + #else + # echo "Warning: Using 'pixie-vm' on path is deprecated. 'pixie' is preferred." + fi fi function set_load_path() { @@ -22,7 +32,7 @@ function set_load_path() { if [ ! -f "project.edn" ] && [ -f "project.pxi" ]; then echo "Warning: 'project.pxi' is deprecated, please use 'project.edn'." echo "To start you can run the following command:" - echo " pixie-vm -l $base_path/src -e '(require dust.project :as p) (p/load-project!) (prn (dissoc @p/*project* :path))'" + echo " $pixie_path -l $base_path/src -e '(require dust.project :as p) (p/load-project!) (prn (dissoc @p/*project* :path))'" echo fi diff --git a/project.pxi b/project.pxi deleted file mode 100644 index 94e2f26..0000000 --- a/project.pxi +++ /dev/null @@ -1,3 +0,0 @@ -(defproject dust "0.1.0-alpha" - :description "Magic fairy dust for Pixie" - :dependencies []) diff --git a/run.pxi b/run.pxi index 75abbf2..e0b2e1b 100644 --- a/run.pxi +++ b/run.pxi @@ -34,17 +34,16 @@ (defn showdoc [ns function] - (let [name (str (if (not= ns "pixie.stdlib") (str ns "/") (str ns "/")))] + (let [name (str (if (= function "/") (str ns) (str ns "/")))] ;loads other possible namespaces in case function is in other namespace (if (= @show-all true) (eval (read-string (str "(require " ns ")")))) - (let [data (meta (eval (read-string (str name function))))] - (print (str "\n " name function "\n\n\t")) - (let [func-name (if (not= (str/index-of function "/") nil) (str function) (str name function))] - (loop [sigs (lazy-seq (:signatures data))] - (when (not= sigs '()) - (print (str/replace (str (lazy-seq (first sigs)) " ") "(" (str "(" func-name " "))) - (recur (rest sigs))))) + (let [data (meta (eval (read-string (str name function)))) func-name (if (and (not= (str/index-of function "/") nil) (not= (str function) "/")) (str function) (str name function))] + (print (str "\n " func-name "\n\n\t")) + (loop [sigs (lazy-seq (:signatures data))] + (when (not= sigs '()) + (print (str/replace (str (lazy-seq (first sigs)) " ") "(" (str "(" func-name " "))) + (recur (rest sigs)))) (if (nil? data) (do @@ -67,17 +66,32 @@ -(defcmd doc +(defcmd ^:no-project doc "Show function documentation. Broaden search using -all" - [function-name & search-all] - (if (= (str (first search-all)) "-all") (reset! show-all true)) - (loop [_ 0] - (when (not= @namespaces '()) - (try (showdoc (str (first @namespaces)) (str function-name)) - (catch e - nil)) - (recur (reset! namespaces (rest @namespaces))))) - (if (= @unknown-command true) (println (str "\n " function-name "\n\n\t Function not found. " (if (not= (str (first search-all)) "-all") (str "Broaden search using -all flag.\n") (str "\n")))))) + [ & args] + (if (empty? args) + (help-cmd "doc") + (let [function-name (first args) search-all (first (rest args))] + (if (and (not= (str/index-of (str function-name) "/") nil) (not= (str function-name) "/") ) + ;test for division operator as function to be documented + (do + (try + (eval (read-string (str "(require " (str/substring function-name 0 (str/index-of function-name "/")) ")"))) + ;load the required namespaces + + (showdoc (str (first @namespaces)) (str function-name)) + (catch e + (reset! unknown-command true))) + (reset! namespaces '()))) + (if (= (str search-all) "-all") (reset! show-all true)) + (loop [_ 0] + (when (not= @namespaces '()) + (try (showdoc (str (first @namespaces)) (if (= function-name "deps") (str "*") (str function-name))) + ; $ dust doc * -> dust doc deps ??? + (catch e + nil)) + (recur (reset! namespaces (rest @namespaces))))) + (if (= @unknown-command true) (println (str "\n " function-name "\n\n\t Function not found. " (if (not= (str search-all) "-all") (str "Broaden search using -all flag.\n") (str "\n")))))))) (defcmd deps "List the dependencies and their versions of the current project."