Class: MGit::RemoveCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/mgit/commands/remove.rb

Instance Method Summary collapse

Methods inherited from Command

#check_arity, create, execute, instance_each, list, load_commands, register_alias, register_command, require_commands_from_directory

Methods included from Output

#perror, #pinfo, #psystem, #ptable, #pwarn

Instance Method Details

#arityObject



16
17
18
# File 'lib/mgit/commands/remove.rb', line 16

def arity
  [1, 1]
end

#descriptionObject



24
25
26
# File 'lib/mgit/commands/remove.rb', line 24

def description
  'remove a repository'
end

#execute(args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/mgit/commands/remove.rb', line 3

def execute(args)
  ptrn = args[0]

  repo = Registry.find do |r|
    r.name == ptrn || r.path == File.expand_path(ptrn)
  end

  fail CommandUsageError.new("Couldn't find repository matching '#{ptrn}'.", self) unless repo

  Registry.remove(repo.name)
  pinfo "Removed repository #{repo.name}."
end

#usageObject



20
21
22
# File 'lib/mgit/commands/remove.rb', line 20

def usage
  'remove <name/path>'
end