fewald-worklog 0.2.16 → 0.2.18
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 +1 -0
- data/lib/printer.rb +11 -1
- data/lib/worklog.rb +17 -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: 226d608638c12cd6ed618d5669d1e675baf2826ec9f7092887cf08b2612bf845
|
4
|
+
data.tar.gz: 897ee2bbd7ee446a2397815632c0738115c7b2ce4e37251ef3197db7cbf1c7fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c313a4c546a9aa10ca55c718fda09a9ec3bedd3e16bea9beaea95cfb0153ac1b2ac3be1f8d06f5a5baa60e33d451bfbb270c2f6ddbc31a381462da6e549dd8db
|
7
|
+
data.tar.gz: bede43615c16b5c457e953c0f30a902cfaeaa4d55dc7ddcc9d00bdfe6f27e9b40676ee94a88d7c2d89d34b6321bd8e0284fd8233c4144c4ee1864a91505e7091
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.18
|
data/lib/cli.rb
CHANGED
@@ -92,6 +92,7 @@ class WorklogCLI < Thor
|
|
92
92
|
EOF
|
93
93
|
option :epics_only, type: :boolean, default: false, desc: 'Show only entries that are marked as epic'
|
94
94
|
option :tags, type: :array, default: [], desc: 'Filter entries by tags. Tags are treated as an OR condition.'
|
95
|
+
option :project, type: :string, desc: 'Filter entries by project key.'
|
95
96
|
def show
|
96
97
|
worklog = Worklog::Worklog.new
|
97
98
|
worklog.show(options)
|
data/lib/printer.rb
CHANGED
@@ -15,7 +15,15 @@ class Printer
|
|
15
15
|
# Prints a whole day of work log entries.
|
16
16
|
# If date_inline is true, the date is printed inline with the time.
|
17
17
|
# If epics_only is true, only epic entries are printed.
|
18
|
-
|
18
|
+
# @param daily_log [DailyLog] The daily log containing entries.
|
19
|
+
# @param date_inline [Boolean] If true, the date is printed inline with the time.
|
20
|
+
# @param epics_only [Boolean] If true, only epic entries are printed.
|
21
|
+
# @param filter [Hash] A hash of filters to apply to the entries.
|
22
|
+
# @return [void]
|
23
|
+
# @example
|
24
|
+
# printer.print_day(daily_log, date_inline: true, epics_only: false, project: 'xyz')
|
25
|
+
# printer.print_day(daily_log, date_inline: false, epics_only: true)
|
26
|
+
def print_day(daily_log, date_inline = false, epics_only = false, filter = {})
|
19
27
|
daily_log.date = Date.strptime(daily_log.date, '%Y-%m-%d') unless daily_log.date.respond_to?(:strftime)
|
20
28
|
|
21
29
|
date_string = daily_log.date.strftime('%a, %B %-d, %Y')
|
@@ -24,6 +32,8 @@ class Printer
|
|
24
32
|
daily_log.entries.each do |entry|
|
25
33
|
next if epics_only && !entry.epic?
|
26
34
|
|
35
|
+
next unless filter.compact.all? { |k, v| entry.send(k) == v }
|
36
|
+
|
27
37
|
print_entry(daily_log, entry, date_inline)
|
28
38
|
end
|
29
39
|
end
|
data/lib/worklog.rb
CHANGED
@@ -115,6 +115,20 @@ module Worklog
|
|
115
115
|
WorkLogger.info Rainbow("Updated work log for #{options[:date]}").green
|
116
116
|
end
|
117
117
|
|
118
|
+
# Show the work log for a specific date range or a single date.
|
119
|
+
#
|
120
|
+
# @param options [Hash] the options hash containing date range or single date.
|
121
|
+
# @option options [Integer] :days the number of days to show from today (default: 1).
|
122
|
+
# @option options [String] :from the start date in 'YYYY-MM-DD' format.
|
123
|
+
# @option options [String] :to the end date in 'YYYY-MM-DD' format.
|
124
|
+
# @option options [String] :date a specific date in 'YYYY-MM-DD' format.
|
125
|
+
# @option options [Boolean] :epics_only whether to show only entries with epics (default: false).
|
126
|
+
# @option options [String] :project the project key to filter entries by project.
|
127
|
+
#
|
128
|
+
# @example
|
129
|
+
# worklog.show(days: 7)
|
130
|
+
# worklog.show(from: '2023-10-01', to: '2023-10-31')
|
131
|
+
# worklog.show(date: '2023-10-01')
|
118
132
|
def show(options = {})
|
119
133
|
people = @storage.load_people!
|
120
134
|
printer = Printer.new(people)
|
@@ -126,7 +140,7 @@ module Worklog
|
|
126
140
|
printer.no_entries(start_date, end_date)
|
127
141
|
else
|
128
142
|
entries.each do |entry|
|
129
|
-
printer.print_day(entry, entries.size > 1, options[:epics_only])
|
143
|
+
printer.print_day(entry, entries.size > 1, options[:epics_only], project: options[:project])
|
130
144
|
end
|
131
145
|
end
|
132
146
|
end
|
@@ -193,8 +207,8 @@ module Worklog
|
|
193
207
|
projects.each_value do |project|
|
194
208
|
puts "#{Rainbow(project.name).gold} (#{project.key})"
|
195
209
|
puts " Description: #{project.description}" if project.description
|
196
|
-
puts " Start date: #{project.start_date}" if project.start_date
|
197
|
-
puts " End date: #{project.end_date}" if project.end_date
|
210
|
+
puts " Start date: #{project.start_date.strftime('%b %d, %Y')}" if project.start_date
|
211
|
+
puts " End date: #{project.end_date.strftime('%b %d, %Y')}" if project.end_date
|
198
212
|
puts " Status: #{project.status}" if project.status
|
199
213
|
end
|
200
214
|
puts 'No projects found.' if projects.empty?
|