mirror of
https://github.com/janet-lang/janet
synced 2024-11-30 20:09:54 +00:00
Fix #759 - Add -E flag for one-liners.
Use the `short-fn` DSL here for argument passing.
This commit is contained in:
parent
685d2b460c
commit
846c9e5e12
@ -2,6 +2,7 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
## 1.17.0 - 2021-08-21
|
## 1.17.0 - 2021-08-21
|
||||||
|
- Add the `-E` flag for one-liners with the `short-fn` syntax for argument passing.
|
||||||
- Add support for threaded abstract types. Threaded abstract types can easily be shared between threads.
|
- Add support for threaded abstract types. Threaded abstract types can easily be shared between threads.
|
||||||
- Deprecate the `thread` library. Use threaded channels and ev instead.
|
- Deprecate the `thread` library. Use threaded channels and ev instead.
|
||||||
- Channels can now be marshalled.
|
- Channels can now be marshalled.
|
||||||
|
6
janet.1
6
janet.1
@ -5,6 +5,7 @@ janet \- run the Janet language abstract machine
|
|||||||
.B janet
|
.B janet
|
||||||
[\fB\-hvsrpnqk\fR]
|
[\fB\-hvsrpnqk\fR]
|
||||||
[\fB\-e\fR \fISOURCE\fR]
|
[\fB\-e\fR \fISOURCE\fR]
|
||||||
|
[\fB\-E\fR \fISOURCE ...ARGUMENTS\fR]
|
||||||
[\fB\-l\fR \fIMODULE\fR]
|
[\fB\-l\fR \fIMODULE\fR]
|
||||||
[\fB\-m\fR \fIPATH\fR]
|
[\fB\-m\fR \fIPATH\fR]
|
||||||
[\fB\-c\fR \fIMODULE JIMAGE\fR]
|
[\fB\-c\fR \fIMODULE JIMAGE\fR]
|
||||||
@ -162,6 +163,11 @@ Read raw input from stdin and forgo prompt history and other readline-like featu
|
|||||||
Execute a string of Janet source. Source code is executed in the order it is encountered, so earlier
|
Execute a string of Janet source. Source code is executed in the order it is encountered, so earlier
|
||||||
arguments are executed before later ones.
|
arguments are executed before later ones.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.BR \-E\ code arguments
|
||||||
|
Execute a single Janet expression as a Janet short-fn, passing the remaining command line arguments to the expression. This allows
|
||||||
|
more concise one-liners with command line arguments.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BR \-d
|
.BR \-d
|
||||||
Enable debug mode. On all terminating signals as well the debug signal, this will
|
Enable debug mode. On all terminating signals as well the debug signal, this will
|
||||||
|
@ -2425,7 +2425,7 @@
|
|||||||
(def res (compile form (fiber/getenv (fiber/current)) "eval"))
|
(def res (compile form (fiber/getenv (fiber/current)) "eval"))
|
||||||
(if (= (type res) :function)
|
(if (= (type res) :function)
|
||||||
(res)
|
(res)
|
||||||
(error (res :error))))
|
(error (get res :error))))
|
||||||
|
|
||||||
(defn parse
|
(defn parse
|
||||||
`Parse a string and return the first value. For complex parsing, such as for a repl with error handling,
|
`Parse a string and return the first value. For complex parsing, such as for a repl with error handling,
|
||||||
@ -3540,6 +3540,7 @@
|
|||||||
-v : Print the version string
|
-v : Print the version string
|
||||||
-s : Use raw stdin instead of getline like functionality
|
-s : Use raw stdin instead of getline like functionality
|
||||||
-e code : Execute a string of janet
|
-e code : Execute a string of janet
|
||||||
|
-E code arguments... : Evaluate an expression as a short-fn with arguments
|
||||||
-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
|
-R : Disables loading profile.janet when JANET_PROFILE is present
|
||||||
@ -3578,6 +3579,15 @@
|
|||||||
(set *no-file* false)
|
(set *no-file* false)
|
||||||
(eval-string (in args (+ i 1)))
|
(eval-string (in args (+ i 1)))
|
||||||
2)
|
2)
|
||||||
|
"E" (fn E-switch [i &]
|
||||||
|
(set *no-file* false)
|
||||||
|
(def subargs (array/slice args (+ i 2)))
|
||||||
|
(def src ~|,(parse (in args (+ i 1))))
|
||||||
|
(def thunk (compile src))
|
||||||
|
(if (function? thunk)
|
||||||
|
((thunk) ;subargs)
|
||||||
|
(error (get thunk :error)))
|
||||||
|
math/inf)
|
||||||
"d" (fn [&] (set *debug* true) 1)
|
"d" (fn [&] (set *debug* true) 1)
|
||||||
"w" (fn [i &] (set *warn-level* (get-lint-level i)) 2)
|
"w" (fn [i &] (set *warn-level* (get-lint-level i)) 2)
|
||||||
"x" (fn [i &] (set *error-level* (get-lint-level i)) 2)
|
"x" (fn [i &] (set *error-level* (get-lint-level i)) 2)
|
||||||
|
Loading…
Reference in New Issue
Block a user