mirror of
https://github.com/janet-lang/janet
synced 2024-11-10 10:49:54 +00:00
Merge branch 'master' into ev
This commit is contained in:
commit
bd95f742c0
@ -2,6 +2,8 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## Unreleased - ???
|
||||
- Add `jpm list-pkgs` subcommand to see which package aliases are in the listing.
|
||||
- Add `jpm list-installed` subcommand to see which packages are installed.
|
||||
- Add `math/int-min`, `math/int-max`, `math/int32-min`, and `math/int32-max` for getting integer limits.
|
||||
- The gc interval is now autotuned, to prevent very bad gc behavior.
|
||||
- Improvements to the bytecode compiler, Janet will now generate more efficient bytecode.
|
||||
|
28
jpm
28
jpm
@ -1106,6 +1106,9 @@ Unprivileged project subcommands:
|
||||
run rule : run a rule. Can also run custom rules added via (phony "task" [deps...] ...)
|
||||
or (rule "ouput.file" [deps...] ...).
|
||||
rules : list rules available with run.
|
||||
list-installed : list installed packages in the current syspath.
|
||||
list-pkgs (search) : list packages in the package listing that the contain the string search.
|
||||
If no search pattern is given, prints the entire package listing.
|
||||
rule-tree (root rule) (depth) : Print a nice tree to see what rules depend on other rules.
|
||||
Optionally provide a root rule to start printing from, and a
|
||||
max depth to print. Without these options, all rules will print
|
||||
@ -1186,6 +1189,29 @@ Flags are:
|
||||
(def ks (sort (seq [k :keys (dyn :rules)] k)))
|
||||
(each k ks (print k)))
|
||||
|
||||
(defn list-installed
|
||||
[]
|
||||
(def xs
|
||||
(seq [x :in (os/dir (find-manifest-dir))
|
||||
:when (string/has-suffix? ".jdn" x)]
|
||||
(string/slice x 0 -5)))
|
||||
(sort xs)
|
||||
(each x xs (print x)))
|
||||
|
||||
(defn list-pkgs
|
||||
[&opt search]
|
||||
(def [ok _] (module/find "pkgs"))
|
||||
(unless ok
|
||||
(eprint "no local package listing found. Run `jpm update-pkgs` to get listing.")
|
||||
(os/exit 1))
|
||||
(def pkgs-mod (require "pkgs"))
|
||||
(def ps
|
||||
(seq [p :keys (get-in pkgs-mod ['packages :value] [])
|
||||
:when (if search (string/find search p) true)]
|
||||
p))
|
||||
(sort ps)
|
||||
(each p ps (print p)))
|
||||
|
||||
(defn update-pkgs
|
||||
[]
|
||||
(install-git (dyn :pkglist default-pkglist)))
|
||||
@ -1227,6 +1253,8 @@ Flags are:
|
||||
"debug-repl" jpm-debug-repl
|
||||
"rule-tree" show-rule-tree
|
||||
"show-paths" show-paths
|
||||
"list-installed" list-installed
|
||||
"list-pkgs" list-pkgs
|
||||
"clear-cache" clear-cache
|
||||
"clear-manifest" clear-manifest
|
||||
"run" local-rule
|
||||
|
9
jpm.1
9
jpm.1
@ -139,6 +139,15 @@ date or too large, clear-cache will remove the cache and jpm will rebuild it
|
||||
when needed. clear-cache is a global command, so a project.janet is not
|
||||
required.
|
||||
|
||||
.TP
|
||||
.BR list-installed
|
||||
List all installed packages in the current syspath.
|
||||
|
||||
.TP
|
||||
.BR list-pkgs [\fBsearch\fR]
|
||||
List all package aliases in the current package listing that contain the given search string.
|
||||
If no search string is given, prints the entire listing.
|
||||
|
||||
.TP
|
||||
.BR clear-manifest
|
||||
jpm creates a manifest directory that contains a list of all installed files.
|
||||
|
@ -497,7 +497,7 @@
|
||||
(defmacro eachk
|
||||
"Loop over each key in ds. Returns nil."
|
||||
[x ds & body]
|
||||
(each-template x ds :each body))
|
||||
(each-template x ds :keys body))
|
||||
|
||||
(defmacro eachp
|
||||
"Loop over each (key, value) pair in ds. Returns nil."
|
||||
|
@ -61,5 +61,11 @@ int table_test() {
|
||||
assert(janet_equals(janet_table_get(t2, janet_csymbolv("t2key1")), janet_wrap_integer(10)));
|
||||
assert(janet_equals(janet_table_get(t2, janet_csymbolv("t2key2")), janet_wrap_integer(100)));
|
||||
|
||||
assert(t2->count == 4);
|
||||
assert(janet_equals(janet_table_remove(t2, janet_csymbolv("t2key1")), janet_wrap_integer(10)));
|
||||
assert(t2->count == 3);
|
||||
assert(janet_equals(janet_table_remove(t2, janet_csymbolv("t2key2")), janet_wrap_integer(100)));
|
||||
assert(t2->count == 2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ Janet janet_table_rawget(JanetTable *t, Janet key) {
|
||||
Janet janet_table_remove(JanetTable *t, Janet key) {
|
||||
JanetKV *bucket = janet_table_find(t, key);
|
||||
if (NULL != bucket && !janet_checktype(bucket->key, JANET_NIL)) {
|
||||
Janet ret = bucket->key;
|
||||
Janet ret = bucket->value;
|
||||
t->count--;
|
||||
t->deleted++;
|
||||
bucket->key = janet_wrap_nil();
|
||||
|
@ -315,4 +315,9 @@
|
||||
|
||||
(assert (= 40 counter) "if-with 1")
|
||||
|
||||
(def a @[])
|
||||
(eachk x [:a :b :c :d]
|
||||
(array/push a x))
|
||||
(assert (deep= (range 4) a) "eachk 1")
|
||||
|
||||
(end-suite)
|
||||
|
Loading…
Reference in New Issue
Block a user