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



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

def description
  'remove a repository'
end

#execute(args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 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 = Registry.find do |repo|
    repo.name == ptrn || repo.path == File.expand_path(ptrn)
  end
  
  raise CommandUsageError.new("Couldn't find repository matching '#{ptrn}'.", self) unless repo

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

#usageObject



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

def usage
  'remove <name/path>'
end