Class: GitBundle::CLI

Inherits:
Object
  • Object
show all
Includes:
Console
Defined in:
lib/git_bundle/cli.rb

Constant Summary

Constants included from Console

GitBundle::Console::COLORS

Instance Method Summary collapse

Methods included from Console

#puts_attention, #puts_error, #puts_heading, #puts_prompt, #puts_repo_heading

Constructor Details

#initializeCLI

Returns a new instance of CLI.



5
6
7
8
# File 'lib/git_bundle/cli.rb', line 5

def initialize
  @errors = []
  load_repositories
end

Instance Method Details

#exec_all(*argv) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/git_bundle/cli.rb', line 24

def exec_all(*argv)
  exec_errors = []
  @repositories.each do |repo|
    puts_repo_heading(repo)
    puts repo.execute_git(argv.join(' '))
    exec_errors << repo.name unless $?.exitstatus == 0
  end

  @errors << "Command failed in #{exec_errors.join(', ')}." unless exec_errors.empty?
end

#invoke(args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/git_bundle/cli.rb', line 10

def invoke(args)
  case args[0]
    when nil, '--help', 'help'
      puts `git #{args.join(' ')}`.gsub('git', 'gitb')
    when 'push'
      push = GitBundle::Push.new(@repositories, args[1..-1])
      push.invoke if push.prompt_confirm
    else
      exec_all(args)
  end

  puts_error @errors.join('\n') unless @errors.empty?
end