Class: Homebrew::Cmd::CleanupCmd Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::Cmd::CleanupCmd
- Defined in:
- cmd/cleanup.rb,
sorbet/rbi/dsl/homebrew/cmd/cleanup_cmd.rbi
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Defined Under Namespace
Classes: Args
Instance Method Summary collapse
- #args ⇒ Homebrew::Cmd::CleanupCmd::Args private
- #run ⇒ void private
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?
Constructor Details
This class inherits a constructor from Homebrew::AbstractCommand
Instance Method Details
#args ⇒ Homebrew::Cmd::CleanupCmd::Args
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
10 |
# File 'sorbet/rbi/dsl/homebrew/cmd/cleanup_cmd.rbi', line 10 def args; end |
#run ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'cmd/cleanup.rb', line 34 def run days = args.prune.presence&.then do |prune| case prune when /\A\d+\Z/ prune.to_i when "all" 0 else raise UsageError, "`--prune` expects an integer or `all`." end end cleanup = Cleanup.new(*args.named, dry_run: args.dry_run?, scrub: args.s?, days:) if args.prune_prefix? cleanup.prune_prefix_symlinks_and_directories return end cleanup.clean!(quiet: args.quiet?, periodic: false) unless cleanup.disk_cleanup_size.zero? disk_space = disk_usage_readable(cleanup.disk_cleanup_size) if args.dry_run? ohai "This operation would free approximately #{disk_space} of disk space." else ohai "This operation has freed approximately #{disk_space} of disk space." end end return if cleanup.unremovable_kegs.empty? ofail <<~EOS Could not cleanup old kegs! Fix your permissions on: #{cleanup.unremovable_kegs.join "\n "} EOS end |