2021-01-18 21:20:11 -05:00

38 lines
722 B
Ruby

# typed: true
# frozen_string_literal: true
require "formula"
require "cli/parser"
module Homebrew
extend T::Sig
module_function
sig { returns(CLI::Parser) }
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`.
EOS
named_args :installed_formula, min: 1
end
end
def pin
args = pin_args.parse
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