Class: Wlog::CliInterface

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

Overview

included here, and should be factored out in the future.

Constant Summary

Constants included from StaticConfigurations

StaticConfigurations::AppDirectory, StaticConfigurations::AppName, StaticConfigurations::ConfigDirectory, StaticConfigurations::ConfigFile, StaticConfigurations::DataDirectory, StaticConfigurations::DefaultDb, StaticConfigurations::TaintFile, StaticConfigurations::TemplateDir

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCliInterface

This is the main entry point of the application. Therefore when we init, we want to trigger the table creation stuff.



26
27
28
29
# File 'lib/wlog/ui/cli_interface.rb', line 26

def initialize
  @db = DbRegistry.new(nil)
  @strmaker = SysConfig.string_decorator
end

Class Method Details

.list_databasesObject

TODO this might need to be factored out elsewhere



58
59
60
61
62
63
# File 'lib/wlog/ui/cli_interface.rb', line 58

def self.list_databases
  puts "Available Worklog databases: "
  Dir["#{StaticConfigurations::DataDirectory}*"].each do |db|
    puts "[%8d bytes] %s" % [File.size(db), db]
  end
end

Instance Method Details

#runObject

Run the interface



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/wlog/ui/cli_interface.rb', line 32

def run
  cmd = "default"
  label = @strmaker.white('wlog')
  until cmd == "end" do 
    cmd = Readline.readline("[#{label}] ") || "end"
    cmd.chomp!

    case cmd
    when /^archive/ then archive cmd
    when /^showattach/ then show_attach
    when /^outattach/  then output_attach
    when /^generateinvoice/ then generate_invoice
    when /^attach/ then attach
    when /^focus/  then focus(cmd)
    when /^new/    then new_issue
    when /^(ls|show)/   then show_issues
    when /^outcsv/ then outcsv
    when /^delete/ then delete_issue(cmd)
    when /^help/   then print_help
    when /^search/ then search
    when /^config/ then config
    end
  end
end