Class: WorklogCLI

Inherits:
Thor
  • Object
show all
Includes:
StringHelper
Defined in:
lib/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



32
33
34
35
36
# File 'lib/cli.rb', line 32

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

Instance Attribute Details

#configObject

Returns the value of attribute config.



24
25
26
# File 'lib/cli.rb', line 24

def config
  @config
end

#storageObject

Returns the value of attribute storage.



24
25
26
# File 'lib/cli.rb', line 24

def storage
  @storage
end

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/cli.rb', line 38

def self.exit_on_failure?
  true
end

Instance Method Details

#add(message) ⇒ Object



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

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

#editObject



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

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

#people(person = nil) ⇒ Object



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

def people(person = nil)
  worklog = Worklog::Worklog.new
  worklog.people(person, options)
end

#projects(options = {}) ⇒ Object



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

def projects(options = {})
  worklog = Worklog::Worklog.new
  worklog.projects(options)
end

#removeObject



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

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

#serverObject



132
133
134
135
# File 'lib/cli.rb', line 132

def server
  worklog = Worklog::Worklog.new
  worklog.server
end

#showObject



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

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

#statsObject



138
139
140
141
# File 'lib/cli.rb', line 138

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

#summaryObject



154
155
156
157
# File 'lib/cli.rb', line 154

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

#tags(tag = nil) ⇒ Object



126
127
128
129
# File 'lib/cli.rb', line 126

def tags(tag = nil)
  worklog = Worklog::Worklog.new
  worklog.tags(tag, options)
end

#versionObject



160
161
162
# File 'lib/cli.rb', line 160

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