Split remove command into separate file (#9529)

This commit is contained in:
Maximilian Downey Twiss
2024-04-04 22:11:36 +11:00
committed by GitHub
parent c19e0ca3e9
commit 14a81ec42c
4 changed files with 82 additions and 92 deletions

View File

@@ -128,14 +128,14 @@ pkg_update_arr.each do |pkg|
print "\nWould you like to remove deprecated package #{pkg[:pkg_name].capitalize}? [y/N] "
case $stdin.gets.chomp.downcase
when 'y', 'yes'
@in_fixup = true
begin
remove pkg[:pkg_name]
rescue NoMethodError # This won't work the first time crew update happens, since this requires an update to crew.
puts "Please rerun 'crew update' to allow for removal of #{pkg[:pkg_name].capitalize}.".orange
puts "#{pkg[:pkg_name].capitalize} not removed.".lightblue
# Create a minimal Package object and pass it to Command.remove
pkg_object = Package
pkg_object.instance_eval do
self.name = pkg[:pkg_name]
def self.preremove; end
def self.remove; end
end
@in_fixup = false
Command.remove(pkg_object, @opt_verbose)
else
puts "#{pkg[:pkg_name].capitalize} not removed.".lightblue
end