raco pkg show: add -v'/--version' argument for selecting a Racket version

This is sortof a step toward `raco pkg migrate'.
This commit is contained in:
Matthew Flatt 2012-12-21 16:18:16 -07:00
parent fdcd030e54
commit 61e0610b2a
3 changed files with 12 additions and 4 deletions

View File

@ -31,6 +31,8 @@
(make-parameter #f))
(define current-install-version-specific?
(make-parameter #t))
(define current-show-version
(make-parameter (version)))
(define current-pkg-error
(make-parameter (lambda args (apply error 'pkg args))))
@ -101,7 +103,7 @@
(build-path (cond
[(current-install-system-wide?) (find-lib-dir)]
[(current-install-version-specific?)
(build-path (find-system-path 'addon-dir) (version))]
(build-path (find-system-path 'addon-dir) (current-show-version))]
[else
(find-system-path 'addon-dir)])
"pkgs"))
@ -1124,6 +1126,8 @@
(parameter/c boolean?)]
[current-install-version-specific?
(parameter/c boolean?)]
[current-show-version
(parameter/c string?)]
[current-pkg-error
(parameter/c procedure?)]
[pkg-desc

View File

@ -1,5 +1,6 @@
#lang racket/base
(require racket/function
(require (only-in racket/base [version r:version])
racket/function
raco/command-name
"lib.rkt"
"commands.rkt"
@ -113,12 +114,13 @@
[#:bool installation ("-i") "Show only the installation-wide package database"]
[#:bool shared ("-s") "Show only the user-specific all-version package database"]
[#:bool user ("-u") "Show only the user- and version-specific package database"]
[(#:str #f) version ("-v") "Show only user--specific packages for specified version"]
#:args ()
(define only-mode (cond
[installation 'i]
[shared 's]
[user 'u]
[else #f]))
[else (if version 'u #f)]))
(for ([mode '(i s u)])
(when (or (eq? mode only-mode) (not only-mode))
(unless only-mode
@ -128,7 +130,8 @@
[(u) "User-specific, version-specific:"])))
(parameterize ([current-install-system-wide? (eq? mode 'i)]
[current-install-version-specific? (eq? mode 'u)]
[current-pkg-error (pkg-error 'show)])
[current-pkg-error (pkg-error 'show)]
[current-show-version (or version (r:version))])
(with-package-lock
(show-cmd (if only-mode "" " "))))))]
[config

View File

@ -291,6 +291,7 @@ listed, this command fails atomically. It accepts the following @nonterm{option}
@item{@DFlag{installation} or @Flag{i} --- Show only installation-wide packages.}
@item{@DFlag{user} or @Flag{u} --- Show only user-specific, version-specific packages.}
@item{@DFlag{shared} or @Flag{s} --- Show only user-specific, all-version packages.}
@item{@DFlag{version} @nonterm{vers} or @Flag{v} @nonterm{vers} --- Show only user-specific packages for Racket version @nonterm{vers}.}
]
}