Add list-pkgs and list-installed to jpm.

This commit is contained in:
Calvin Rose 2020-07-05 17:43:39 -05:00
parent 68a12d1d17
commit a45509d28e
5 changed files with 35 additions and 1 deletions

View File

@ -2,6 +2,7 @@
All notable changes to this project will be documented in this file.
## Unreleased - ???
- 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.

19
jpm
View File

@ -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,20 @@ Flags are:
(def ks (sort (seq [k :keys (dyn :rules)] k)))
(each k ks (print k)))
(defn list-installed
[]
(each x (os/dir (find-manifest-dir))
(if (string/has-suffix? ".jdn" x)
(print (string/slice x 0 -5)))))
(defn list-pkgs
[&opt search]
(def pkgs-mod (require "pkgs"))
(eachk p (get-in pkgs-mod ['packages :value] [])
(if search
(if (string/find search p) (print p))
(print p))))
(defn update-pkgs
[]
(install-git (dyn :pkglist default-pkglist)))
@ -1227,6 +1244,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
View File

@ -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.

View File

@ -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."

View File

@ -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)