From 989eacebc74437a1d38d50cfd5a5fcc2b08c9ad6 Mon Sep 17 00:00:00 2001 From: Alex Oloo <alex@achielit.com> Date: Sat, 26 Dec 2015 02:51:20 +0200 Subject: [PATCH 1/6] Bugs fixed, invalid input exception handling -Added support to query "/" -Inexplicable behaviour when dust doc * is called -specific namespaces can be searched for --- run.pxi | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/run.pxi b/run.pxi index 75abbf2..2bc0b46 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 @@ -69,15 +68,30 @@ (defcmd 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." From 31ed0ed6b4fce78359f728a729e92856e7f3dbff Mon Sep 17 00:00:00 2001 From: alekcz <alekcz@gmail.com> Date: Mon, 25 Jan 2016 17:37:35 +0200 Subject: [PATCH 2/6] `dust doc` works outside of project directories --- run.pxi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.pxi b/run.pxi index 2bc0b46..e0b2e1b 100644 --- a/run.pxi +++ b/run.pxi @@ -66,7 +66,7 @@ -(defcmd doc +(defcmd ^:no-project doc "Show function documentation. Broaden search using -all" [ & args] (if (empty? args) From 20c7c709e5541af52fa8e0ba65c1c8917d920a0a Mon Sep 17 00:00:00 2001 From: Alexander Oloo <alekcz@gmail.com> Date: Fri, 24 Jun 2016 22:08:50 +0200 Subject: [PATCH 3/6] change to use pixie instead of pixie-vm --- dust | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dust b/dust index ffced9b..65b7cf2 100755 --- a/dust +++ b/dust @@ -6,9 +6,9 @@ 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" + echo "Error: 'pixie' must be on your PATH" exit 1 fi From ebcef0ae6f2e4612a5f182f9c93406e477b4edd2 Mon Sep 17 00:00:00 2001 From: Alexander Oloo <alekcz@gmail.com> Date: Fri, 24 Jun 2016 22:13:28 +0200 Subject: [PATCH 4/6] Update help to display pixie instead of pixie-vm --- dust | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dust b/dust index 65b7cf2..a0199f6 100755 --- a/dust +++ b/dust @@ -22,7 +22,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 -l $base_path/src -e '(require dust.project :as p) (p/load-project!) (prn (dissoc @p/*project* :path))'" echo fi From a5998b94a90e1e6e9775e7a19f4dcce1902621ca Mon Sep 17 00:00:00 2001 From: Alexander Oloo <alekcz@gmail.com> Date: Sat, 25 Jun 2016 08:56:35 +0200 Subject: [PATCH 5/6] remove project.pxi (breaks global dust when present) --- project.pxi | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 project.pxi 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 []) From c58ef65188a13d8caefe33d742e985deaa628253 Mon Sep 17 00:00:00 2001 From: Alexander Oloo <alekcz@gmail.com> Date: Sat, 25 Jun 2016 09:31:37 +0200 Subject: [PATCH 6/6] allow pixie-vm, pixie and pxi till we decide --- dust | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/dust b/dust index a0199f6..297c76d 100755 --- a/dust +++ b/dust @@ -8,8 +8,18 @@ base_path=`dirname $base_path` pixie_path=`which pixie` if [ -z "$pixie_path" ]; then - echo "Error: 'pixie' 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 -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