Class: GitJump::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/git_jump/cli.rb

Overview

Command-line interface using OptionParser

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.start(argv) ⇒ Object



8
9
10
# File 'lib/git_jump/cli.rb', line 8

def self.start(argv)
  new.run(argv)
end

Instance Method Details

#run(argv) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/git_jump/cli.rb', line 12

def run(argv)
  @global_options = { config: nil, quiet: false, verbose: false }

  if argv.empty?
    print_help
    exit(0)
  end

  command = argv.shift

  case command
  when "setup"
    setup_command(argv)
  when "install"
    install_command(argv)
  when "add"
    add_command(argv)
  when "list"
    list_command(argv)
  when "jump"
    jump_command(argv)
  when "clear"
    clear_command(argv)
  when "status"
    status_command(argv)
  when "version", "-v", "--version"
    version_command
  when "help", "-h", "--help"
    print_help
  else
    warn "Unknown command: #{command}"
    warn "Run 'git-jump help' for usage information."
    exit(1)
  end
end