Port Homebrew::Cmd::Unpin

This commit is contained in:
Douglas Eichelberger 2024-04-01 11:48:40 -07:00
parent 5ccb0b0567
commit f8caae06f7
2 changed files with 24 additions and 25 deletions

View File

@ -1,34 +1,32 @@
# typed: true
# typed: strict
# frozen_string_literal: true
require "abstract_command"
require "formula"
require "cli/parser"
module Homebrew
module_function
module Cmd
class Unpin < AbstractCommand
cmd_args do
description <<~EOS
Unpin <formula>, allowing them to be upgraded by `brew upgrade` <formula>.
See also `pin`.
EOS
sig { returns(CLI::Parser) }
def unpin_args
Homebrew::CLI::Parser.new do
description <<~EOS
Unpin <formula>, allowing them to be upgraded by `brew upgrade` <formula>.
See also `pin`.
EOS
named_args :installed_formula, min: 1
end
named_args :installed_formula, min: 1
end
end
def unpin
args = unpin_args.parse
args.named.to_resolved_formulae.each do |f|
if f.pinned?
f.unpin
elsif !f.pinnable?
onoe "#{f.name} not installed"
else
opoo "#{f.name} not pinned"
sig { override.void }
def run
args.named.to_resolved_formulae.each do |f|
if f.pinned?
f.unpin
elsif !f.pinnable?
onoe "#{f.name} not installed"
else
opoo "#{f.name} not pinned"
end
end
end
end
end

View File

@ -1,8 +1,9 @@
# frozen_string_literal: true
require "cmd/shared_examples/args_parse"
require "cmd/unpin"
RSpec.describe "brew unpin" do
RSpec.describe Homebrew::Cmd::Unpin do
it_behaves_like "parseable arguments"
it "unpins a Formula's version", :integration_test do