39 lines
830 B
Ruby
Raw Normal View History

2020-11-25 17:03:23 +01:00
# typed: true
# frozen_string_literal: true
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
2020-10-20 12:03:48 +02:00
sig { returns(CLI::Parser) }
2018-11-11 20:06:40 +05:30
def pin_args
Homebrew::CLI::Parser.new do
description <<~EOS
Pin the specified <formula>, preventing them from being upgraded when
issuing the `brew upgrade` <formula> command. See also `unpin`.
Note: Other packages which depend on newer versions of a pinned formula
might not install or run correctly.
2018-11-11 20:06:40 +05:30
EOS
2020-07-30 18:40:10 +02:00
2021-01-10 14:26:40 -05:00
named_args :installed_formula, min: 1
2018-11-11 20:06:40 +05:30
end
end
def pin
2020-07-30 18:40:10 +02:00
args = pin_args.parse
2018-11-11 20:06:40 +05:30
args.named.to_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