fewald-worklog 0.3.14 → 0.3.16
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 +5 -5
- data/lib/printer.rb +9 -1
- data/lib/worklog.rb +26 -5
- 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: e593a4c0712fbf4419176cea214fc137b9449e36a1d05e74e9bba4bc9329e106
|
|
4
|
+
data.tar.gz: 2841ef01cf81a2f9f8c82c07918fe5ec149295d655af19031b8c98082bfe7d84
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 81f2d8cf8527676bc3af134b40f97252c96a464e0fa9c7aaf4f60e7e1463370d2e7cea990df87138ef67d06af4f25e987074ad71f0624abde3db6e4127f4a205
|
|
7
|
+
data.tar.gz: b1d369a79e34f00306cde60819c5bda650edc48326b0daba96557ce8de98af18b570af461ebb1e61d7cd98cbac612af60ca01641b417c55832a7fe687ffbaf03
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.16
|
data/lib/cli.rb
CHANGED
|
@@ -65,7 +65,7 @@ class WorklogCLI < Thor
|
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
desc 'edit', 'Edit a day in the work log. By default, the current date is used.'
|
|
68
|
-
option :date, type: :string, default:
|
|
68
|
+
option :date, type: :string, default: Date.today.to_s
|
|
69
69
|
def edit
|
|
70
70
|
worklog = Worklog::Worklog.new
|
|
71
71
|
worklog.edit(options)
|
|
@@ -84,7 +84,7 @@ class WorklogCLI < Thor
|
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
desc 'remove', 'Remove last entry from the log'
|
|
87
|
-
option :date, type: :string, default:
|
|
87
|
+
option :date, type: :string, default: Date.today.to_s
|
|
88
88
|
def remove
|
|
89
89
|
worklog = Worklog::Worklog.new
|
|
90
90
|
worklog.remove(options)
|
|
@@ -94,7 +94,7 @@ class WorklogCLI < Thor
|
|
|
94
94
|
long_desc <<~LONGDESC
|
|
95
95
|
Show the work log for a specific date or a range of dates. As a default, all items from the current day will be shown.
|
|
96
96
|
LONGDESC
|
|
97
|
-
option :date, type: :string, default:
|
|
97
|
+
option :date, type: :string, default: Date.today.to_s,
|
|
98
98
|
desc: <<~DESC
|
|
99
99
|
Show the work log for a specific date. If this option is provided, --from and --to and --days should not be used.
|
|
100
100
|
DESC
|
|
@@ -105,7 +105,7 @@ class WorklogCLI < Thor
|
|
|
105
105
|
Inclusive end date of the range. Takes precedence over --date, if defined.
|
|
106
106
|
EOF
|
|
107
107
|
option :days, type: :numeric, desc: <<~EOF
|
|
108
|
-
Number of days to show starting from --date. Takes precedence over --from and --to if defined.
|
|
108
|
+
Number of days to show starting from --date. Takes precedence over --from and --to, if defined.
|
|
109
109
|
EOF
|
|
110
110
|
option :epics_only, type: :boolean, default: false, desc: 'Show only entries that are marked as epic'
|
|
111
111
|
option :tags, type: :array, default: [], desc: 'Filter entries by tags. Tags are treated as an OR condition.'
|
|
@@ -135,7 +135,7 @@ class WorklogCLI < Thor
|
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
desc 'tags', 'Show all tags used in the work log'
|
|
138
|
-
option :date, type: :string, default:
|
|
138
|
+
option :date, type: :string, default: Date.today.to_s,
|
|
139
139
|
desc: <<~DESC
|
|
140
140
|
Show the work log for a specific date. If this option is provided, --from and --to and --days should not be used.
|
|
141
141
|
DESC
|
data/lib/printer.rb
CHANGED
|
@@ -29,7 +29,15 @@ class Printer
|
|
|
29
29
|
daily_log.date = Date.strptime(daily_log.date, '%Y-%m-%d') unless daily_log.date.respond_to?(:strftime)
|
|
30
30
|
|
|
31
31
|
date_string = daily_log.date.strftime('%a, %B %-d, %Y')
|
|
32
|
-
|
|
32
|
+
preamble = "Work log for #{Rainbow(date_string).gold}"
|
|
33
|
+
puts preamble unless date_inline
|
|
34
|
+
|
|
35
|
+
# Print only if there are entries to show, especially when epics_only is true
|
|
36
|
+
entries_count = daily_log.entries.count do |entry|
|
|
37
|
+
(!epics_only || entry.epic?) && filter.compact.all? { |k, v| entry.send(k) == v }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
puts Rainbow('-' * preamble.gsub(/\e\[[0-9;]*m/, '').length).gold if entries_count.positive?
|
|
33
41
|
|
|
34
42
|
daily_log.entries.each do |entry|
|
|
35
43
|
next if epics_only && !entry.epic?
|
data/lib/worklog.rb
CHANGED
|
@@ -48,6 +48,11 @@ module Worklog
|
|
|
48
48
|
|
|
49
49
|
attr_reader :config, :storage
|
|
50
50
|
|
|
51
|
+
# The earliest allowed start date for log entries.
|
|
52
|
+
# By default, filters that do not specify a start date will use this date.
|
|
53
|
+
# @return [Date] The earliest allowed start date.
|
|
54
|
+
EARLIEST_START_DATE = Date.new(1980, 1, 1).freeze
|
|
55
|
+
|
|
51
56
|
def initialize(config = nil)
|
|
52
57
|
# Load or use provided configuration
|
|
53
58
|
@config = config || Configuration.load
|
|
@@ -329,7 +334,7 @@ module Worklog
|
|
|
329
334
|
# worklog.tags(nil) # Show all tags for all time
|
|
330
335
|
def tags(tag = nil, options = {})
|
|
331
336
|
if tag.nil? || tag.empty?
|
|
332
|
-
tag_overview
|
|
337
|
+
tag_overview(options)
|
|
333
338
|
else
|
|
334
339
|
tag_detail(tag, options)
|
|
335
340
|
end
|
|
@@ -352,9 +357,16 @@ module Worklog
|
|
|
352
357
|
end
|
|
353
358
|
|
|
354
359
|
# Show overview of all tags used in the work log including their count.
|
|
355
|
-
def tag_overview
|
|
356
|
-
|
|
357
|
-
|
|
360
|
+
def tag_overview(options)
|
|
361
|
+
start_date, end_date = start_end_date(options)
|
|
362
|
+
|
|
363
|
+
all_logs = @storage.days_between(start_date, end_date)
|
|
364
|
+
date_string = if start_date == end_date
|
|
365
|
+
"on #{start_date}"
|
|
366
|
+
else
|
|
367
|
+
"from #{start_date} to #{end_date}"
|
|
368
|
+
end
|
|
369
|
+
puts Rainbow("Tags used in the work log #{date_string}:").gold
|
|
358
370
|
|
|
359
371
|
# Count all tags used in the work log
|
|
360
372
|
tags = all_logs.map(&:entries).flatten.map(&:tags).flatten.compact.tally
|
|
@@ -482,9 +494,18 @@ module Worklog
|
|
|
482
494
|
|
|
483
495
|
start_date = Date.today - options[:days]
|
|
484
496
|
end_date = Date.today
|
|
497
|
+
elsif options[:from] && options[:to]
|
|
498
|
+
# If both from and to are provided
|
|
499
|
+
start_date = DateParser.parse_date_string!(options[:from], true)
|
|
500
|
+
end_date = DateParser.parse_date_string!(options[:to], false)
|
|
485
501
|
elsif options[:from]
|
|
502
|
+
# If only from is provided
|
|
486
503
|
start_date = DateParser.parse_date_string!(options[:from], true)
|
|
487
|
-
end_date =
|
|
504
|
+
end_date = Date.today
|
|
505
|
+
elsif options[:to]
|
|
506
|
+
# If only to is provided
|
|
507
|
+
start_date = EARLIEST_START_DATE
|
|
508
|
+
end_date = DateParser.parse_date_string!(options[:to], false)
|
|
488
509
|
elsif options[:date]
|
|
489
510
|
start_date = Date.strptime(options[:date], '%Y-%m-%d')
|
|
490
511
|
end_date = start_date
|