raco pkg show: include only non-auto by default

This commit is contained in:
Matthew Flatt 2013-07-22 16:20:14 -06:00
parent 92f2d7d386
commit 682916c8fe
3 changed files with 19 additions and 7 deletions

View File

@ -396,14 +396,16 @@ removing any of the @nonterm{pkg}s.
@item{@command/toc{show} @nonterm{option} ... --- Print information about currently installed packages. @item{@command/toc{show} @nonterm{option} ... --- Print information about currently installed packages.
By default, packages are shown for all installation modes (installation-wide, By default, packages are shown for all installation modes (installation-wide,
user- and Racket-version-specific, and user-specific all-version). user- and Racket-version-specific, and user-specific all-version), but only for packages
not marked as auto-installed to fulfill dependencies.
The @exec{show} sub-command accepts The @exec{show} sub-command accepts
the following @nonterm{option}s: the following @nonterm{option}s:
@itemlist[ @itemlist[
@item{@Flag{d} --- Adds a column in the output for the directory the package is installed to.} @item{@Flag{a} or @DFlag{all} --- Includes auto-installed packages in the listing.}
@item{@Flag{d} or @DFlag{dir} --- Adds a column in the output for the directory where the package is installed.}
@item{@DFlag{scope} @nonterm{scope} --- Shows only packages in @nonterm{scope}, which is one of @item{@DFlag{scope} @nonterm{scope} --- Shows only packages in @nonterm{scope}, which is one of
@itemlist[ @itemlist[

View File

@ -1590,7 +1590,9 @@
#:strip strip-mode #:strip strip-mode
to-update)])) to-update)]))
(define (pkg-show indent #:directory? [dir? #f]) (define (pkg-show indent
#:directory? [dir? #f]
#:auto? [show-auto? #f])
(let () (let ()
(define db (read-pkg-db)) (define db (read-pkg-db))
(define pkgs (sort (hash-keys db) string-ci<=?)) (define pkgs (sort (hash-keys db) string-ci<=?))
@ -1599,13 +1601,17 @@
(table-display (table-display
(list* (list*
(append (append
(list (format "~aPackage[*=auto]" indent) (list (format "~aPackage~a"
indent
(if show-auto? "[*=auto]" ""))
"Checksum" "Checksum"
"Source") "Source")
(if dir? (if dir?
(list "Directory") (list "Directory")
empty)) empty))
(for/list ([pkg (in-list pkgs)]) (for/list ([pkg (in-list pkgs)]
#:when (or show-auto?
(not (pkg-info-auto? (hash-ref db pkg)))))
(match-define (pkg-info orig-pkg checksum auto?) (hash-ref db pkg)) (match-define (pkg-info orig-pkg checksum auto?) (hash-ref db pkg))
(append (append
(list (format "~a~a~a" (list (format "~a~a~a"
@ -2304,7 +2310,8 @@
(or/c #f 'skip (listof (or/c path-string? (non-empty-listof path-string?)))))] (or/c #f 'skip (listof (or/c path-string? (non-empty-listof path-string?)))))]
[pkg-show [pkg-show
(->* (string?) (->* (string?)
(#:directory? boolean?) (#:directory? boolean?
#:auto? boolean?)
void?)] void?)]
[pkg-install [pkg-install
(->* ((listof pkg-desc?)) (->* ((listof pkg-desc?))

View File

@ -197,6 +197,7 @@
[show [show
"Show information about installed packages" "Show information about installed packages"
#:once-each #:once-each
[#:bool all ("-a") "Show auto-installed packages, too"]
[#:bool dir ("-d") "Show the directory where the package is installed"] [#:bool dir ("-d") "Show the directory where the package is installed"]
#:once-any #:once-any
[(#:sym scope [installation user shared] #f) scope () [(#:sym scope [installation user shared] #f) scope ()
@ -240,7 +241,9 @@
[current-pkg-error (pkg-error 'show)] [current-pkg-error (pkg-error 'show)]
[current-pkg-scope-version (or version (r:version))]) [current-pkg-scope-version (or version (r:version))])
(with-pkg-lock/read-only (with-pkg-lock/read-only
(pkg-show (if only-mode "" " ") #:directory? dir)))))] (pkg-show (if only-mode "" " ")
#:auto? all
#:directory? dir)))))]
[create [create
"Bundle a package from a directory or installed package" "Bundle a package from a directory or installed package"
#:once-any #:once-any