Port Homebrew::Cmd::Autoremove

This commit is contained in:
Douglas Eichelberger 2024-03-29 16:20:40 -07:00
parent c50fb2dbd2
commit a8f8c65d93
2 changed files with 18 additions and 18 deletions

View File

@ -1,27 +1,26 @@
# typed: strict
# frozen_string_literal: true
require "abstract_command"
require "cleanup"
require "cli/parser"
module Homebrew
sig { returns(CLI::Parser) }
def self.autoremove_args
Homebrew::CLI::Parser.new do
description <<~EOS
Uninstall formulae that were only installed as a dependency of another formula and are now no longer needed.
EOS
switch "-n", "--dry-run",
description: "List what would be uninstalled, but do not actually uninstall anything."
module Cmd
class Autoremove < AbstractCommand
cmd_args do
description <<~EOS
Uninstall formulae that were only installed as a dependency of another formula and are now no longer needed.
EOS
switch "-n", "--dry-run",
description: "List what would be uninstalled, but do not actually uninstall anything."
named_args :none
named_args :none
end
sig { override.void }
def run
Cleanup.autoremove(dry_run: args.dry_run?)
end
end
end
sig { void }
def self.autoremove
args = autoremove_args.parse
Cleanup.autoremove(dry_run: args.dry_run?)
end
end

View File

@ -1,8 +1,9 @@
# frozen_string_literal: true
require "cmd/autoremove"
require "cmd/shared_examples/args_parse"
RSpec.describe "brew autoremove" do
RSpec.describe Homebrew::Cmd::Autoremove do
it_behaves_like "parseable arguments"
describe "integration test" do