Class: Wlog::CliInterface

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

Overview

Author

Simon Symeonidis

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.list_databases_commandObject

TODO the commands should be factored out



53
54
55
56
57
58
59
60
61
# File 'lib/wlog/cli_interface.rb', line 53

def self.list_databases_command
  puts "Available Worklog databases: "
  Dir["#{StaticConfigurations::DATA_DIRECTORY}*"].each do |n|
    print "[%8d bytes]" % File.size(n)
    print "  "
    print n
    puts
  end
end

Instance Method Details

#runObject

Run the interface



8
9
10
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
# File 'lib/wlog/cli_interface.rb', line 8

def run
  cmd = "default"
  until cmd == "end" do 
    print "[wlog::] "
    cmd = $stdin.gets
    cmd ||= "end"
    cmd.chomp!

    case cmd
    when "new"
      puts "Enter work description:"
      print "  "
      new_entry_command
      puts "ok"

    when "show"
      puts "Showing latest log entries" 
      show_entries_command

    when "outcsv"
      puts "Exporting to CSV."
      fh = File.open("out.csv", "w")
      fh.write(make_csv)
      fh.close

    when "delete"
      print "Remove task with id: "
      delete_entry_command

    when "search"
      search_term

    when "concat" 
      concat_description

    when "replace"
      replace_pattern

    when "help"
      print_help
    end
  end
end