mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Port Homebrew::Cmd::Unpin
This commit is contained in:
parent
5ccb0b0567
commit
f8caae06f7
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user