Class: Wlog::CliInterface
- Inherits:
-
Object
- Object
- Wlog::CliInterface
- 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, StaticConfigurations::TemplateOutputDir, StaticConfigurations::TemplateSampleFile
Class Method Summary collapse
-
.list_databases ⇒ Object
TODO this might need to be factored out elsewhere.
Instance Method Summary collapse
-
#initialize ⇒ CliInterface
constructor
This is the main entry point of the application.
-
#run ⇒ Object
Run the interface.
Constructor Details
#initialize ⇒ CliInterface
This is the main entry point of the application. Therefore when we init, we want to trigger the table creation stuff.
27 28 29 |
# File 'lib/wlog/ui/cli_interface.rb', line 27 def initialize @strmaker = SysConfig.string_decorator end |
Class Method Details
.list_databases ⇒ Object
TODO this might need to be factored out elsewhere
57 58 59 60 61 62 |
# File 'lib/wlog/ui/cli_interface.rb', line 57 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
#run ⇒ Object
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 |
# 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 /^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 when /^git/ then GitUi.new.run when /^templates/ then TemplateUi.new.run when /^invoices/ then InvoiceUi.new.run end end end |