cleanup: add --prune-prefix option.

From https://discourse.brew.sh/t/error-calling-brew-prune-is-disabled/4142/4 and https://github.com/github/homebrew-bootstrap/pull/72 it seems this is worth having as a dedicated flag.
This commit is contained in:
Mike McQuaid 2019-02-13 09:39:21 +00:00
parent 9084a629a5
commit e7c5d91151
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
4 changed files with 13 additions and 1 deletions

View File

@ -22,6 +22,8 @@ module Homebrew
description: "Scrub the cache, including downloads for even the latest versions. "\
"Note downloads for any installed formula or cask will still not be deleted. "\
"If you want to delete those too: `rm -rf \"$(brew --cache)\"`"
switch "--prune-prefix",
description: "Only prune the symlinks and directories from the prefix and remove no other files."
switch :verbose
switch :debug
end
@ -31,6 +33,10 @@ module Homebrew
cleanup_args.parse
cleanup = Cleanup.new(*args.remaining, dry_run: args.dry_run?, scrub: args.s?, days: args.prune&.to_i)
if args.prune_prefix?
cleanup.prune_prefix_symlinks_and_directories
return
end
cleanup.clean!

View File

@ -23,6 +23,6 @@ module Homebrew
def prune
prune_args.parse
odisabled("'brew prune'", "'brew cleanup'")
odisabled("'brew prune'", "'brew cleanup --prune-prefix'")
end
end

View File

@ -63,6 +63,8 @@ only do this for the specified formulae and casks.
Show what would be removed, but do not actually remove anything.
* `-s`:
Scrub the cache, including downloads for even the latest versions. Note downloads for any installed formula or cask will still not be deleted. If you want to delete those too: `rm -rf "$(brew --cache)"`
* `--prune-prefix`:
Only prune the symlinks and directories from the prefix and remove no other files.
### `command` *`cmd`*

View File

@ -62,6 +62,10 @@ Show what would be removed, but do not actually remove anything\.
\fB\-s\fR
Scrub the cache, including downloads for even the latest versions\. Note downloads for any installed formula or cask will still not be deleted\. If you want to delete those too: \fBrm \-rf "$(brew \-\-cache)"\fR
.
.TP
\fB\-\-prune\-prefix\fR
Only prune the symlinks and directories from the prefix and remove no other files\.
.
.SS "\fBcommand\fR \fIcmd\fR"
Display the path to the file which is used when invoking \fBbrew\fR \fIcmd\fR\.
.