fewald-worklog 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.version +1 -1
- data/lib/cli.rb +15 -3
- data/lib/log_entry.rb +1 -1
- data/lib/worklog.rb +45 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58355177c4287e00546bceb657e475a665a6a0ee374d57e836f220c1e7e57762
|
4
|
+
data.tar.gz: a071e07481282a7e9d857a32ec7e7fe01d71aff05ed1ededf456a5bef253dca1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2b996725ae935188acdfff6c1e71c81ceae62afe2386259a5687e8726967003fad557b0ba8d71bb28d91a13f50138b67a8165643c7a0ce75c33cce4bf5a2cf0
|
7
|
+
data.tar.gz: 5c5bb1134e3eda63975de71857401d7ae1aae24e264e65be97cee2de9fcf75c0407405478e44afc4238bd4cf6c2aab6615204b7617a25967e32d9978b2382ff3
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.5
|
data/lib/cli.rb
CHANGED
@@ -16,7 +16,6 @@ require 'printer'
|
|
16
16
|
require 'statistics'
|
17
17
|
require 'storage'
|
18
18
|
require 'string_helper'
|
19
|
-
require 'summary'
|
20
19
|
require 'version'
|
21
20
|
require 'webserver'
|
22
21
|
|
@@ -104,9 +103,22 @@ class WorklogCLI < Thor
|
|
104
103
|
end
|
105
104
|
|
106
105
|
desc 'tags', 'Show all tags used in the work log'
|
107
|
-
|
106
|
+
option :date, type: :string, default: DateTime.now.strftime('%Y-%m-%d'),
|
107
|
+
desc: <<~DESC
|
108
|
+
Show the work log for a specific date. If this option is provided, --from and --to and --days should not be used.
|
109
|
+
DESC
|
110
|
+
option :from, type: :string, desc: <<~EOF
|
111
|
+
Inclusive start date of the range. Takes precedence over --date, if defined.
|
112
|
+
EOF
|
113
|
+
option :to, type: :string, desc: <<~EOF
|
114
|
+
Inclusive end date of the range. Takes precedence over --date, if defined.
|
115
|
+
EOF
|
116
|
+
option :days, type: :numeric, desc: <<~EOF
|
117
|
+
Number of days to show starting from --date. Takes precedence over --from and --to if defined.
|
118
|
+
EOF
|
119
|
+
def tags(tag = nil)
|
108
120
|
worklog = Worklog.new
|
109
|
-
worklog.tags(options)
|
121
|
+
worklog.tags(tag, options)
|
110
122
|
end
|
111
123
|
|
112
124
|
desc 'server', 'Start the work log server'
|
data/lib/log_entry.rb
CHANGED
@@ -31,7 +31,7 @@ class LogEntry
|
|
31
31
|
end
|
32
32
|
|
33
33
|
# Returns the message string with formatting without the time.
|
34
|
-
# @param
|
34
|
+
# @param known_people Hash[String, Person] A hash of people with their handles as keys.
|
35
35
|
def message_string(known_people = nil)
|
36
36
|
# replace all mentions of people with their names.
|
37
37
|
msg = @message.dup
|
data/lib/worklog.rb
CHANGED
@@ -14,6 +14,7 @@ require 'worklogger'
|
|
14
14
|
require 'string_helper'
|
15
15
|
require 'printer'
|
16
16
|
require 'statistics'
|
17
|
+
require 'summary'
|
17
18
|
|
18
19
|
# Main class providing all worklog functionality.
|
19
20
|
# This class is the main entry point for the application.
|
@@ -138,9 +139,25 @@ class Worklog
|
|
138
139
|
end
|
139
140
|
end
|
140
141
|
|
141
|
-
|
142
|
-
|
142
|
+
# Show all tags used in the work log or details for a specific tag
|
143
|
+
#
|
144
|
+
# @param tag [String, nil] the tag to show details for, or nil to show all tags
|
145
|
+
# @param options [Hash] the options hash containing date range
|
146
|
+
# @return [void]
|
147
|
+
#
|
148
|
+
# @example
|
149
|
+
# worklog.tags('example_tag', from: '2023-10-01', to: '2023-10-31')
|
150
|
+
# worklog.tags(nil) # Show all tags for all time
|
151
|
+
def tags(tag = nil, options = {})
|
152
|
+
if tag.nil? || tag.empty?
|
153
|
+
tag_overview
|
154
|
+
else
|
155
|
+
tag_detail(tag, options)
|
156
|
+
end
|
157
|
+
end
|
143
158
|
|
159
|
+
def tag_overview
|
160
|
+
all_logs = @storage.all_days
|
144
161
|
puts Rainbow('Tags used in the work log:').gold
|
145
162
|
|
146
163
|
# Count all tags used in the work log
|
@@ -153,6 +170,29 @@ class Worklog
|
|
153
170
|
tags.sort.each { |k, v| puts "#{Rainbow(k.ljust(max_len)).gold}: #{v} #{pluralize(v, 'occurrence')}" }
|
154
171
|
end
|
155
172
|
|
173
|
+
# Show detailed information about a specific tag
|
174
|
+
#
|
175
|
+
# @param tag [String] the tag to show details for
|
176
|
+
# @param options [Hash] the options hash containing date range
|
177
|
+
# @return [void]
|
178
|
+
#
|
179
|
+
# @example
|
180
|
+
# worklog.tag_detail('example_tag', from: '2023-10-01', to: '2023-10-31')
|
181
|
+
def tag_detail(tag, options)
|
182
|
+
printer = Printer.new(@storage.load_people!)
|
183
|
+
start_date, end_date = start_end_date(options)
|
184
|
+
|
185
|
+
@storage.days_between(start_date, end_date).each do |daily_log|
|
186
|
+
next unless daily_log.tags.include?(tag)
|
187
|
+
|
188
|
+
daily_log.entries.each do |entry|
|
189
|
+
next unless entry.tags.include?(tag)
|
190
|
+
|
191
|
+
printer.print_entry(daily_log, entry, true)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
156
196
|
def stats(_options = {})
|
157
197
|
stats = Statistics.new(@config).calculate
|
158
198
|
puts "#{format_left('Total days')}: #{stats.total_days}"
|
@@ -207,9 +247,11 @@ class Worklog
|
|
207
247
|
elsif options[:from]
|
208
248
|
start_date = DateParser.parse_date_string!(options[:from], true)
|
209
249
|
end_date = DateParser.parse_date_string!(options[:to], false) if options[:to]
|
210
|
-
|
250
|
+
elsif options[:date]
|
211
251
|
start_date = Date.strptime(options[:date], '%Y-%m-%d')
|
212
252
|
end_date = start_date
|
253
|
+
else
|
254
|
+
raise ArgumentError, 'No date range specified. Use --days, --from, --to or --date options.'
|
213
255
|
end
|
214
256
|
[start_date, end_date]
|
215
257
|
end
|