Class: Wlog::GitUi

Inherits:
Object
  • Object
show all
Defined in:
lib/wlog/ui/git_ui.rb

Overview

Author:

  • Simon Symeonidis

Instance Method Summary collapse

Constructor Details

#initializeGitUi

Returns a new instance of GitUi.



7
8
9
# File 'lib/wlog/ui/git_ui.rb', line 7

def initialize
  @strmaker = SysConfig.string_decorator
end

Instance Method Details



49
50
51
52
53
54
55
56
57
# File 'lib/wlog/ui/git_ui.rb', line 49

def print_help
  ['ls, show', 'list the current git repository settings',
   'set', 'set repo and author for currnet git repository',
   'unset', 'unsets git repository settings',
   'help', 'print this menu'].each_with_index do |cmd,ix|
     print "  " if ix % 2 == 1
     puts cmd
   end
end

#runObject



11
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
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/wlog/ui/git_ui.rb', line 11

def run
  cmd = "default"

  until cmd == "end" do
    cmd = Readline.readline("[#{@strmaker.blue('git')}] ")

    case cmd
    when /^set/
      path = Readline.readline("Path to git repo (eg: project/.git/): ")

      unless File.directory? path
        puts @strmaker.red("That doesn't look like a git repo. Nothing done")
        next
      end

      author = Readline.readline("git author: ")

      # Set the git repo in the db (so one git repo per db)
      KeyValue.put!("git", path)
      KeyValue.put!("author", author)

      when /^unset/
        KeyValue.put!("git", "")

      when /^(ls|show)/
        print '  repo: '
        puts @strmaker.green(KeyValue.get("git"))
        print '  auth: '
        puts @strmaker.yellow(KeyValue.get("author"))

    when /^help/
      print_help

    end
  end

  private

  def print_help
    ['ls, show', 'list the current git repository settings',
     'set', 'set repo and author for currnet git repository',
     'unset', 'unsets git repository settings',
     'help', 'print this menu'].each_with_index do |cmd,ix|
       print "  " if ix % 2 == 1
       puts cmd
     end
  end
end