Class: Pod::Command::Bin::Source::Delete

Inherits:
Pod::Command::Bin::Source show all
Defined in:
lib/cocoapods-meitu-bin/command/bin/source/delete.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pod::Command::Bin::Source

#source_dir, #target_path

Methods included from CBin::SpecFilesHelper

#binary_spec, #binary_spec_files, #binary_template_spec, #binary_template_spec_file, #binary_template_spec_files, #clear_binary_spec_file_if_needed, #code_spec, #code_spec_files, #create_binary_spec_file, #find_spec_file, #spec_files

Methods included from CBin::SourcesHelper

#binary_source, #code_source_list, #sources_manager, #sources_option, #valid_sources

Constructor Details

#initialize(argv) ⇒ Delete

Returns a new instance of Delete.



23
24
25
26
27
# File 'lib/cocoapods-meitu-bin/command/bin/source/delete.rb', line 23

def initialize(argv)
  @names = argv.shift_argument
  @all = argv.flag?('all', false)
  super
end

Class Method Details

.optionsObject



17
18
19
20
21
# File 'lib/cocoapods-meitu-bin/command/bin/source/delete.rb', line 17

def self.options
  [
    %w[--all 删除所有二进制对应的源码]
  ].concat(super).uniq
end

Instance Method Details

#runObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/cocoapods-meitu-bin/command/bin/source/delete.rb', line 29

def run
  if @names.nil? && !@all
    raise Informative, "请输入要删除的Pod库名(多个库中间用逗号分开)或者添加`--all`删除全部的源码"
  end
  if @all
    UI.puts "删除全部源码".yellow
    FileUtils.rm_rf(source_dir)
    UI.puts "删除完成".green
    return
  end
  unless @names.nil?
    name_arr = @names.split(',')
    name_arr.each do |name|
      UI.puts "删除`#{name}`".yellow
      dir = "#{source_dir}/#{name}"
      unless File.exist?(dir)
        UI.puts "`#{name}`不存在".red
        next
      end
      FileUtils.rm_rf(dir)
      UI.puts "删除`#{name}`成功".green
    end
  end
end