mirror of
https://github.com/janet-lang/janet
synced 2024-11-25 01:37:19 +00:00
Merge pull request #589 from yumaikas/master
Add support for a profile.janet
This commit is contained in:
commit
95af205681
@ -3285,7 +3285,8 @@
|
|||||||
|
|
||||||
(if-let [jp (getenv-alias "JANET_PATH")] (setdyn :syspath jp))
|
(if-let [jp (getenv-alias "JANET_PATH")] (setdyn :syspath jp))
|
||||||
(if-let [jp (getenv-alias "JANET_HEADERPATH")] (setdyn :headerpath jp))
|
(if-let [jp (getenv-alias "JANET_HEADERPATH")] (setdyn :headerpath jp))
|
||||||
|
(if-let [jprofile (getenv-alias "JANET_PROFILE")] (setdyn :profilepath jprofile))
|
||||||
|
|
||||||
# Flag handlers
|
# Flag handlers
|
||||||
(def handlers
|
(def handlers
|
||||||
{"h" (fn [&]
|
{"h" (fn [&]
|
||||||
@ -3299,6 +3300,7 @@
|
|||||||
-e code : Execute a string of janet
|
-e code : Execute a string of janet
|
||||||
-d : Set the debug flag in the REPL
|
-d : Set the debug flag in the REPL
|
||||||
-r : Enter the REPL after running all scripts
|
-r : Enter the REPL after running all scripts
|
||||||
|
-R : Disables loading profile.janet when JANET_PROFILE is present
|
||||||
-p : Keep on executing if there is a top-level error (persistent)
|
-p : Keep on executing if there is a top-level error (persistent)
|
||||||
-q : Hide logo (quiet)
|
-q : Hide logo (quiet)
|
||||||
-k : Compile scripts but do not execute (flycheck)
|
-k : Compile scripts but do not execute (flycheck)
|
||||||
@ -3332,7 +3334,8 @@
|
|||||||
(set *no-file* false)
|
(set *no-file* false)
|
||||||
(eval-string (in args (+ i 1)))
|
(eval-string (in args (+ i 1)))
|
||||||
2)
|
2)
|
||||||
"d" (fn [&] (set *debug* true) 1)})
|
"d" (fn [&] (set *debug* true) 1)
|
||||||
|
"R" (fn [&] (setdyn :profilepath nil) 1)})
|
||||||
|
|
||||||
(defn- dohandler [n i &]
|
(defn- dohandler [n i &]
|
||||||
(def h (in handlers n))
|
(def h (in handlers n))
|
||||||
@ -3374,6 +3377,9 @@
|
|||||||
(file/flush stdout)
|
(file/flush stdout)
|
||||||
(file/read stdin :line buf))
|
(file/read stdin :line buf))
|
||||||
(def env (make-env))
|
(def env (make-env))
|
||||||
|
(when-let [profile.janet (dyn :profilepath)]
|
||||||
|
(def new-env (dofile profile.janet :exit true))
|
||||||
|
(merge-module env new-env "" false))
|
||||||
(if *debug* (put env :debug true))
|
(if *debug* (put env :debug true))
|
||||||
(def getter (if *raw-stdin* getstdin getline))
|
(def getter (if *raw-stdin* getstdin getline))
|
||||||
(defn getchunk [buf p]
|
(defn getchunk [buf p]
|
||||||
|
Loading…
Reference in New Issue
Block a user