mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
37 lines
705 B
Ruby
37 lines
705 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "formula"
|
|
require "cli/parser"
|
|
|
|
module Homebrew
|
|
module_function
|
|
|
|
def pin_args
|
|
Homebrew::CLI::Parser.new do
|
|
usage_banner <<~EOS
|
|
`pin` <formula>
|
|
|
|
Pin the specified <formula>, preventing them from being upgraded when
|
|
issuing the `brew upgrade` <formula> command. See also `unpin`.
|
|
EOS
|
|
switch :debug
|
|
end
|
|
end
|
|
|
|
def pin
|
|
pin_args.parse
|
|
|
|
raise FormulaUnspecifiedError if args.remaining.empty?
|
|
|
|
ARGV.resolved_formulae.each do |f|
|
|
if f.pinned?
|
|
opoo "#{f.name} already pinned"
|
|
elsif !f.pinnable?
|
|
onoe "#{f.name} not installed"
|
|
else
|
|
f.pin
|
|
end
|
|
end
|
|
end
|
|
end
|