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 = load_configuration
  @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



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

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

#editObject



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

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

#people(person = nil) ⇒ Object



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

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

#removeObject



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

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

#serverObject



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

def server
  worklog = Worklog.new
  worklog.server
end

#showObject



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

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

#statsObject



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

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

#summaryObject



147
148
149
150
# File 'lib/cli.rb', line 147

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

#tags(tag = nil) ⇒ Object



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

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

#versionObject



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

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