From e22242df56432f04c50670f1118017b3988f4745 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 15 Dec 2014 08:49:23 -0700 Subject: [PATCH] raco pkg: default `--deps` to `search-ask` in interactive mode The implemented default for `raco pkg update` actually depended on the way that a package is installed, and it's difficult to reason about or to implement the default that is suggested by the documentation. Meanwhile, `search-ask` seems the most sensible always in interactive mode (now that we have a way to specify batch mode). --- pkgs/racket-doc/pkg/scribblings/pkg.scrbl | 11 ++++++----- pkgs/racket-test/tests/pkg/tests-deps.rkt | 14 +++++++------- racket/collects/pkg/main.rkt | 15 +++++++-------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/pkgs/racket-doc/pkg/scribblings/pkg.scrbl b/pkgs/racket-doc/pkg/scribblings/pkg.scrbl index 205dcc3cf8..8b9e8cee21 100644 --- a/pkgs/racket-doc/pkg/scribblings/pkg.scrbl +++ b/pkgs/racket-doc/pkg/scribblings/pkg.scrbl @@ -442,13 +442,12 @@ sub-commands. @item{@DFlag{deps} @nonterm{behavior} --- Selects the behavior for dependencies, where @nonterm{behavior} is one of @itemlist[ @item{@exec{fail} --- Cancels the installation if dependencies are uninstalled or version requirements are unmet. - This behavior is the default for non-@tech{interactive mode} for a @nonterm{pkg-source} that is not a @tech{package name}.} + This behavior is the default for non-@tech{interactive mode}.} @item{@exec{force} --- Installs the package(s) despite missing dependencies or version requirements. Forcing an installation may leave package content in an inconsistent state.} @item{@exec{search-ask} --- Looks for dependencies (when uninstalled) or updates (when version requirements are unmet) via the configured @tech{package catalogs}, - but asks if you would like the packages installed or updated. This behavior is the default in @tech{interactive mode} for a - @nonterm{pkg-source} that is a @tech{package name}.} + but asks if you would like the packages installed or updated. This behavior is the default in @tech{interactive mode}.} @item{@exec{search-auto} --- Like @exec{search-ask}, but does not ask for permission to install or update.} ]} @@ -580,7 +579,8 @@ sub-commands. @history[#:changed "6.1.1.5" @elem{Added the @DFlag{batch}, @DFlag{clone}, and @DFlag{multi-clone} flags.} - #:changed "6.1.1.6" @elem{Added the @DFlag{no-trash} flag.}]} + #:changed "6.1.1.6" @elem{Added the @DFlag{no-trash} flag, and changed + the @DFlag{deps} default to depend only on interactive mode.}]} @subcommand{@command/toc{update} @nonterm{option} ... @nonterm{pkg-source} ... @@ -681,7 +681,8 @@ the given @nonterm{pkg-source}s. @DFlag{multi-clone} flags, and added update of enclosing package when no arguments are provided.} - #:changed "6.1.1.6" @elem{Added the @DFlag{no-trash} flag.}]} + #:changed "6.1.1.6" @elem{Added the @DFlag{no-trash} flag, and changed + the @DFlag{deps} default to depend only on interactive mode.}]} @subcommand{@command/toc{remove} @nonterm{option} ... @nonterm{pkg} ... --- Attempts to remove the given packages. By default, if a package is the dependency diff --git a/pkgs/racket-test/tests/pkg/tests-deps.rkt b/pkgs/racket-test/tests/pkg/tests-deps.rkt index 1493759a4e..40b2f59fc8 100644 --- a/pkgs/racket-test/tests/pkg/tests-deps.rkt +++ b/pkgs/racket-test/tests/pkg/tests-deps.rkt @@ -25,10 +25,10 @@ (shelly-case "local - fail (default)" $ "racket -e '(require pkg-test2)'" =exit> 1 - $ "raco pkg install test-pkgs/pkg-test2.zip" =exit> 1 - $ "raco pkg install test-pkgs/pkg-test1.zip" =exit> 0 + $ "raco pkg install --batch test-pkgs/pkg-test2.zip" =exit> 1 + $ "raco pkg install --batch test-pkgs/pkg-test1.zip" =exit> 0 $ "raco pkg show" =exit> 0 - $ "raco pkg install test-pkgs/pkg-test2.zip" =exit> 0 + $ "raco pkg install --batch test-pkgs/pkg-test2.zip" =exit> 0 $ "racket -e '(require pkg-test2)'" =exit> 0 $ "racket -e '(require pkg-test2/contains-dep)'" =exit> 0 $ "raco pkg remove pkg-test2" @@ -39,9 +39,9 @@ (shelly-case "local - fail (default, single-collection)" $ "racket -e '(require pkg-test3)'" =exit> 1 - $ "raco pkg install test-pkgs/pkg-test3.zip" =exit> 1 - $ "raco pkg install test-pkgs/pkg-test1.zip" =exit> 0 - $ "raco pkg install test-pkgs/pkg-test3.zip" =exit> 0 + $ "raco pkg install --batch test-pkgs/pkg-test3.zip" =exit> 1 + $ "raco pkg install --batch test-pkgs/pkg-test1.zip" =exit> 0 + $ "raco pkg install --batch test-pkgs/pkg-test3.zip" =exit> 0 $ "racket -e '(require pkg-test3)'" =exit> 0 $ "raco pkg remove pkg-test3")) @@ -49,7 +49,7 @@ (shelly-case "local - looks at all packages given on cmdline" $ "racket -e '(require pkg-test2)'" =exit> 1 - $ "raco pkg install test-pkgs/pkg-test2.zip test-pkgs/pkg-test1.zip" =exit> 0 + $ "raco pkg install --batch test-pkgs/pkg-test2.zip test-pkgs/pkg-test1.zip" =exit> 0 $ "racket -e '(require pkg-test2)'" =exit> 0 $ "racket -e '(require pkg-test2/contains-dep)'" =exit> 0 $ "raco pkg remove pkg-test2" diff --git a/racket/collects/pkg/main.rkt b/racket/collects/pkg/main.rkt index 398cf35fa4..0fef1f8593 100644 --- a/racket/collects/pkg/main.rkt +++ b/racket/collects/pkg/main.rkt @@ -234,9 +234,9 @@ (pkg-install #:from-command-line? #t #:dep-behavior (or (and auto 'search-auto) deps - (if batch - 'fail - #f)) ; 'search-ask for a package-name source, etc. + (cond + [batch 'fail] + [else 'search-ask])) #:all-platforms? all-platforms #:force? force #:ignore-checksums? ignore-checksums @@ -328,9 +328,9 @@ #:all? all #:dep-behavior (or (and auto 'search-auto) deps - (if batch - 'fail - #f)) ; 'search-ask for a package-name source, etc. + (cond + [batch 'fail] + [else 'search-ask])) #:all-platforms? all-platforms #:force? force #:ignore-checksums? ignore-checksums @@ -662,8 +662,7 @@ " and asks for permission to auto-install" " search-auto: like `search-ask', but does not ask for permission")]) #:install-dep-desc - ("where the default is `search-ask' if is a package name" - "in interactive mode, `fail' otherwise") + ("where the default is `search-ask' in interactive mode, `fail' otherwise") #:install-force-flags ([#:bool all-platforms () "Follow package dependencies for all platforms"] [#:bool force () "Ignore conflicts"]