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

#clear_line, #parallel, #puts_attention, #puts_error, #puts_heading, #puts_prompt, #puts_repo_heading, #puts_repo_heading_switch, #puts_stay_on_line, #puts_wait_line

Constructor Details

#initializeCLI

Returns a new instance of CLI.



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

def initialize
  @errors = []
  @project = GitBundle::Project.new
end

Instance Method Details

#invoke(args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 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'
      GitBundle::Commands::Push.new(@project, args[1..-1]).invoke
    when 'checkout'
      GitBundle::Commands::Checkout.new(@project, args[1..-1]).invoke
    when '--version'
      GitBundle::Commands::Version.new.invoke
    else
      GitBundle::Commands::Generic.new(@project, args).invoke
  end
rescue Bundler::GemfileNotFound => e
  puts_error("Could not find Gemfile in the current directory")
end