Class: Homebrew::Cmd::CleanupCmd Private

Inherits:
AbstractCommand show all
Defined in:
sorbet/rbi/dsl/homebrew/cmd/cleanup_cmd.rbi,
cmd/cleanup.rb

Overview

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.

DO NOT EDIT MANUALLY This is an autogenerated file for dynamic methods in Homebrew::Cmd::CleanupCmd. Please instead update this file by running bin/tapioca dsl Homebrew::Cmd::CleanupCmd.

Defined Under Namespace

Classes: Args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::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.



9
# File 'sorbet/rbi/dsl/homebrew/cmd/cleanup_cmd.rbi', line 9

def args; end

#runvoid

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