37 lines
874 B
Ruby
Raw Normal View History

2024-04-01 09:44:14 -07:00
# typed: strict
# frozen_string_literal: true
2024-04-01 09:44:14 -07:00
require "abstract_command"
require "formula"
module Homebrew
2024-04-01 09:44:14 -07:00
module Cmd
class Pin < AbstractCommand
cmd_args do
description <<~EOS
Pin the specified <formula>, preventing them from being upgraded when
issuing the `brew upgrade` <formula> command. See also `unpin`.
2016-09-26 01:44:51 +02:00
2024-04-01 09:44:14 -07:00
*Note:* Other packages which depend on newer versions of a pinned formula
might not install or run correctly.
EOS
2024-04-01 09:44:14 -07:00
named_args :installed_formula, min: 1
end
2018-11-11 20:06:40 +05:30
2024-04-01 09:44:14 -07:00
sig { override.void }
def run
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
end
end