Class: MGit::RemoveCommand

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

Instance Method Summary collapse

Methods inherited from Command

create, #help, instance_each, list, register_alias, register_command

Instance Method Details

#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
15
16
17
18
# File 'lib/mgit/commands/remove.rb', line 3

def execute(args)
  raise TooFewArgumentsError.new(self) if args.size == 0
  raise TooManyArgumentsError.new(self) if args.size > 1

  ptrn = args[0]

  repo = Repository.find do |name, path|
    name == ptrn || path == File.expand_path(ptrn)
  end
  
  raise CommandUsageError.new("Couldn't find repository matching '#{ptrn}'.", self) unless repo

  name = repo[0]
  Repository.remove(name)
  puts "Removed repository #{name}.".yellow
end

#usageObject



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

def usage
  'remove <name/path>'
end