Class: MGit::CloneCommand

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

Instance Method Summary collapse

Methods inherited from Command

execute, instance_each, list, register_alias, register_command

Methods included from Output

#perror, #pinfo, #ptable, #pwarn

Instance Method Details

#arityObject



11
12
13
# File 'lib/mgit/commands/clone.rb', line 11

def arity
  [1, nil]
end

#descriptionObject



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

def description
  'clone repository and add to mgit'
end

#execute(args) ⇒ Object

Raises:



3
4
5
6
7
8
9
# File 'lib/mgit/commands/clone.rb', line 3

def execute(args)
  log = `git clone #{args.join(' ')}`
  raise GitError.new('Clone command failed.') if $?.exitstatus != 0

  m = /Cloning into '(.*)'/.match(log.split("\n").first)
  Command.execute('add', [m[1]])
end

#usageObject



15
16
17
# File 'lib/mgit/commands/clone.rb', line 15

def usage
  'clone [options] <url> [<directory>]'
end