Class: MGit::CloneCommand

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

Instance Method Summary collapse

Methods inherited from Command

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

Methods included from Output

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

Instance Method Details

#arityObject



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

def arity
  [1, nil]
end

#descriptionObject



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

def description
  'clone repository and add to mgit'
end

#execute(args) ⇒ Object



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

def execute(args)
  log = System::git("clone #{args.join(' ')}", { :raise => true, :print_stderr => true }).stdout
  
  m = /Cloning into '(.*)'/.match(log.split("\n").first)
  Command.execute('add', [m[1]])
end

#usageObject



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

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