Class: WorklogCLI

Inherits:
Thor
  • Object
show all
Includes:
StringHelper
Defined in:
worklog/cli.rb

Overview

CLI for the work log application

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from StringHelper

#format_left, #pluralize

Constructor Details

#initialize(args = [], options = {}, config = {}) ⇒ WorklogCLI

Initialize the CLI with the given arguments, options, and configuration



33
34
35
36
37
# File 'worklog/cli.rb', line 33

def initialize(args = [], options = {}, config = {})
  @config = load_configuration
  @storage = Storage.new(@config)
  super
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



25
26
27
# File 'worklog/cli.rb', line 25

def config
  @config
end

#storageObject

Returns the value of attribute storage.



25
26
27
# File 'worklog/cli.rb', line 25

def storage
  @storage
end

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'worklog/cli.rb', line 39

def self.exit_on_failure?
  true
end

Instance Method Details

#add(message) ⇒ Object



57
58
59
60
# File 'worklog/cli.rb', line 57

def add(message)
  worklog = Worklog.new
  worklog.add(message, options)
end

#editObject



64
65
66
67
# File 'worklog/cli.rb', line 64

def edit
  worklog = Worklog.new
  worklog.edit(options)
end

#peopleObject



101
102
103
104
# File 'worklog/cli.rb', line 101

def people
  worklog = Worklog.new
  worklog.people(options)
end

#removeObject



71
72
73
74
# File 'worklog/cli.rb', line 71

def remove
  worklog = Worklog.new
  worklog.remove(options)
end

#serverObject



113
114
115
116
# File 'worklog/cli.rb', line 113

def server
  app = WorkLogApp.new(@storage)
  WorkLogServer.new(app).start
end

#showObject



95
96
97
98
# File 'worklog/cli.rb', line 95

def show
  worklog = Worklog.new
  worklog.show(options)
end

#statsObject



119
120
121
122
# File 'worklog/cli.rb', line 119

def stats
  worklog = Worklog.new
  worklog.stats(options)
end

#summaryObject



135
136
137
138
# File 'worklog/cli.rb', line 135

def summary
  worklog = Worklog.new
  worklog.summary(options)
end

#tagsObject



107
108
109
110
# File 'worklog/cli.rb', line 107

def tags
  worklog = Worklog.new
  worklog.tags(options)
end

#versionObject



141
142
143
# File 'worklog/cli.rb', line 141

def version
  puts "Worklog #{current_version} running on Ruby #{RUBY_VERSION}"
end