35 lines
674 B
Ruby
Raw Normal View History

require "formula"
2019-04-17 18:25:08 +09:00
require "cli/parser"
module Homebrew
2016-09-26 01:44:51 +02:00
module_function
2018-11-11 20:06:40 +05:30
def pin_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`pin` <formula>
2018-11-11 20:06:40 +05:30
Pin the specified <formula>, preventing them from being upgraded when
issuing the `brew upgrade` <formula> command. See also `unpin`.
2018-11-11 20:06:40 +05:30
EOS
switch :debug
end
end
def pin
2018-11-11 20:06:40 +05:30
pin_args.parse
raise FormulaUnspecifiedError if args.remaining.empty?
2015-05-17 21:06:23 +08:00
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