From f8caae06f7da3e17ddbd3af9efa62e0036a37a43 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Mon, 1 Apr 2024 11:48:40 -0700 Subject: [PATCH] Port Homebrew::Cmd::Unpin --- Library/Homebrew/cmd/unpin.rb | 46 ++++++++++++------------- Library/Homebrew/test/cmd/unpin_spec.rb | 3 +- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/Library/Homebrew/cmd/unpin.rb b/Library/Homebrew/cmd/unpin.rb index 9b26e4eda5..e75d15eb43 100644 --- a/Library/Homebrew/cmd/unpin.rb +++ b/Library/Homebrew/cmd/unpin.rb @@ -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 , allowing them to be upgraded by `brew upgrade` . + See also `pin`. + EOS - sig { returns(CLI::Parser) } - def unpin_args - Homebrew::CLI::Parser.new do - description <<~EOS - Unpin , allowing them to be upgraded by `brew upgrade` . - 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 diff --git a/Library/Homebrew/test/cmd/unpin_spec.rb b/Library/Homebrew/test/cmd/unpin_spec.rb index a3ba1df7b2..33912c65fb 100644 --- a/Library/Homebrew/test/cmd/unpin_spec.rb +++ b/Library/Homebrew/test/cmd/unpin_spec.rb @@ -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