Class: Homebrew::Cmd::Prefix

Inherits:
AbstractCommand show all
Includes:
FileUtils
Defined in:
cmd/--prefix.rb

Constant Summary collapse

UNBREWED_EXCLUDE_FILES =
%w[.DS_Store].freeze
UNBREWED_EXCLUDE_PATHS =
%w[
  */.keepme
  .github/*
  bin/brew
  completions/zsh/_brew
  docs/*
  lib/gdk-pixbuf-2.0/*
  lib/gio/*
  lib/node_modules/*
  lib/python[23].[0-9]/*
  lib/python3.[0-9][0-9]/*
  lib/pypy/*
  lib/pypy3/*
  lib/ruby/gems/[12].*
  lib/ruby/site_ruby/[12].*
  lib/ruby/vendor_ruby/[12].*
  manpages/brew.1
  share/pypy/*
  share/pypy3/*
  share/info/dir
  share/man/whatis
  share/mime/*
  texlive/*
].freeze

Instance Attribute Summary

Attributes inherited from AbstractCommand

#args

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, #initialize, parser

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Class Method Details

.command_nameString

Returns:



39
# File 'cmd/--prefix.rb', line 39

def self.command_name = "--prefix"

Instance Method Details

#runvoid

This method returns an undefined value.

Raises:



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'cmd/--prefix.rb', line 61

def run
  raise UsageError, "`--installed` requires a formula argument." if args.installed? && args.no_named?

  if args.unbrewed?
    raise UsageError, "`--unbrewed` does not take a formula argument." unless args.no_named?

    list_unbrewed
  elsif args.no_named?
    puts HOMEBREW_PREFIX
  else
    formulae = args.named.to_resolved_formulae
    prefixes = formulae.filter_map do |f|
      next nil if args.installed? && !f.opt_prefix.exist?

      # this case will be short-circuited by brew.sh logic for a single formula
      f.opt_prefix
    end
    puts prefixes
    if args.installed?
      missing_formulae = formulae.reject(&:optlinked?)
                                 .map(&:name)
      return if missing_formulae.blank?

      raise NotAKegError, <<~EOS
        The following formulae are not installed:
        #{missing_formulae.join(" ")}
      EOS
    end
  end
end