Class: Wlog::IssueUi

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

Overview

Author:

  • Simon

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(issue) ⇒ IssueUi

Returns a new instance of IssueUi.



18
19
20
21
# File 'lib/wlog/ui/issue_ui.rb', line 18

def initialize(issue)
  @issue = issue
  @strmaker = SysConfig.string_decorator
end

Instance Attribute Details

#issueObject

Focusing on the current issue



53
54
55
# File 'lib/wlog/ui/issue_ui.rb', line 53

def issue
  @issue
end

Instance Method Details

#runObject

Start up the interface



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
# File 'lib/wlog/ui/issue_ui.rb', line 24

def run
  cmd = "default"
  until cmd == "end" do
    cmd = Readline.readline("[issue ##{@issue.id}] ") || ""
    cmd.chomp!

    case cmd
    when /^new/       then new_entry
    when /^(ls|show)/ then show_entries
    when /^desc/      then describe_issue
    when /^delete/    then delete_entry(cmd.split.drop 1)
    when /^edit/      then EditHandler.new(@issue).edit_what(cmd.split.drop 1)
    when /^concat/    then concat_description
    when /^replace/   then replace_pattern
    when /^search/    then search_term((cmd.split.drop 1).join ' ')
    when /^lt/        then time(cmd.split.drop 1) # lt for log time
    when /^forget/    then cmd = "end"
    when /^finish/    then finish ? cmd = "end" : nil
    when /^attachout/  then output_attach
    when /^attachls/ then show_attach
    when /^attach/ then attach
    when /^help/      then print_help
    when /^end/       then next
    else puts "Type 'help' for help"
    end
  end
end