diff --git a/CHANGELOG.md b/CHANGELOG.md index 5433d8fd..639de2cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ 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. diff --git a/jpm b/jpm index f19a9e18..9dcb66c7 100755 --- a/jpm +++ b/jpm @@ -1191,17 +1191,26 @@ Flags are: (defn list-installed [] - (each x (os/dir (find-manifest-dir)) - (if (string/has-suffix? ".jdn" x) - (print (string/slice x 0 -5))))) + (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")) - (eachk p (get-in pkgs-mod ['packages :value] []) - (if search - (if (string/find search p) (print p)) - (print p)))) + (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 []