Class: Pixab::MboxRemove

Inherits:
Object
  • Object
show all
Defined in:
lib/mbox/MboxRemove.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo_manager) ⇒ MboxRemove

Returns a new instance of MboxRemove.



7
8
9
# File 'lib/mbox/MboxRemove.rb', line 7

def initialize(repo_manager)
  @repo_manager = repo_manager
end

Instance Attribute Details

#repo_managerObject (readonly)

Returns the value of attribute repo_manager.



5
6
7
# File 'lib/mbox/MboxRemove.rb', line 5

def repo_manager
  @repo_manager
end

Instance Method Details

#remove_repo(commands) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/mbox/MboxRemove.rb', line 33

def remove_repo(commands)
  return if commands.empty?

  execute_commad = "mbox remove"
  commands.each do |command|
    execute_commad += " #{command}"
  end

  `#{execute_commad}`
end

#run(commands) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/mbox/MboxRemove.rb', line 11

def run(commands)
  if commands.empty?
    repo_names = @repo_manager.sub_repo_names
    if !repo_names.empty?
      selected_item_names = Utilities.display_choose_list(repo_names, nil, "仓库", "请选择需要移除的仓库:", nil, nil, true)
      selected_item_names.each do |repo_name|
        remove_repo([repo_name.strip])
      end
    end
  elsif commands[0] == "--all"
    repo_names = @repo_manager.sub_repo_names
    repo_names.each do |repo_name|
      remove_repo([repo_name])
    end
  else
    remove_repo(commands)
  end

  system("mbox status")

end