doing 1.0.86 → 1.0.87

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2af84d93e54c8366719e285303dc11d966f9b83361ae4ac20ca172536465f4ee
4
- data.tar.gz: 7fa72f0ec1ba1a18e45d80c1604910cabb00c8dad485b96d05bd8c3e33a5b4ae
3
+ metadata.gz: 2540726a17efa50ef0cddc29353d8c14a4d921a89fb302711225053faacfbc4d
4
+ data.tar.gz: e4f59cf1e2feda50df653bbbd981e1ab4ad75d807eaf47a8afbad9d98032d27b
5
5
  SHA512:
6
- metadata.gz: 158707f75c6375fb5d684457d0b17c874fb2dc0f9b2e5318a24f055665ed246e69149211fb45487acac2174b2ca9db6ebd62b071af0c283377d5e2fa78f663c2
7
- data.tar.gz: 80bf8ff4da513c0d911afdf5bbeb2589f6a08bf46eb746c5eb610f5ddac1bdc7d7469f1f3eb399e86c4a671358df704c98596841c2f8964d3f81ebe985de1435
6
+ metadata.gz: dabcbefd24a3d099d71eb14c03f71250067e509b385d573405219d3cfaea8a66f6ec526a32547401f249f0fdd82774415ed0da1c95e233aada2f54135de49558
7
+ data.tar.gz: 5b5a5d7800110de9aeaf636b6b6b4947c1923e55ce4f455d2316483c37fcfb30461b818df78c24097ef66f574ed57bdeebf50f77e4f806161212c4d36c86eabd
data/README.md CHANGED
@@ -27,7 +27,7 @@ If there's something I want to look at later but doesn't need to be added to a t
27
27
 
28
28
  ## Installation
29
29
 
30
- The current version of `doing` is <!--VER-->1.0.85<!--END VER-->.
30
+ The current version of `doing` is <!--VER-->1.0.86<!--END VER-->.
31
31
 
32
32
  $ [sudo] gem install doing
33
33
 
data/bin/doing CHANGED
@@ -896,10 +896,22 @@ command :show do |c|
896
896
  c.arg_name 'MAX'
897
897
  c.flag %i[c count], default_value: 0
898
898
 
899
- c.desc 'Age (oldest/newest)'
899
+ c.desc 'Age (oldest|newest)'
900
900
  c.arg_name 'AGE'
901
901
  c.flag %i[a age], default_value: 'newest'
902
902
 
903
+ c.desc 'View entries older than date'
904
+ c.arg_name 'DATE_STRING'
905
+ c.flag [:before]
906
+
907
+ c.desc 'View entries newer than date'
908
+ c.arg_name 'DATE_STRING'
909
+ c.flag [:after]
910
+
911
+ c.desc 'Search filter, surround with slashes for regex (/query/)'
912
+ c.arg_name 'QUERY'
913
+ c.flag [:search]
914
+
903
915
  c.desc 'Sort order (asc/desc)'
904
916
  c.arg_name 'ORDER'
905
917
  c.flag %i[s sort], must_match: /^[ad].*/i, default_value: 'ASC'
@@ -924,6 +936,10 @@ command :show do |c|
924
936
  c.arg_name 'KEY'
925
937
  c.flag [:tag_sort], must_match: /^(?:name|time)/i, default_value: default
926
938
 
939
+ c.desc 'Tag sort direction (asc|desc)'
940
+ c.arg_name 'DIRECTION'
941
+ c.flag [:tag_order], must_match: /^(?:a(?:sc)?|d(?:esc)?)$/i
942
+
927
943
  c.desc 'Only show items with recorded time intervals'
928
944
  c.switch [:only_timed], default_value: false, negatable: false
929
945
 
@@ -979,8 +995,8 @@ command :show do |c|
979
995
  }
980
996
  end
981
997
 
982
- if options[:f]
983
- date_string = options[:f]
998
+ if options[:from]
999
+ date_string = options[:from]
984
1000
  if date_string =~ / (to|through|thru|(un)?til|-+) /
985
1001
  dates = date_string.split(/ (to|through|thru|(un)?til|-+) /)
986
1002
  start = wwid.chronify(dates[0])
@@ -993,22 +1009,31 @@ command :show do |c|
993
1009
  dates = [start, finish]
994
1010
  end
995
1011
 
996
- options[:t] = true if options[:totals]
1012
+ options[:times] = true if options[:totals]
997
1013
 
998
1014
  tags_color = wwid.config.key?('tags_color') ? wwid.config['tags_color'] : nil
999
1015
 
1000
1016
  options[:sort_tags] = options[:tag_sort] =~ /^n/i
1017
+ tag_order = if options[:tag_order]
1018
+ options[:tag_order] =~ /^d/i ? 'desc' : 'asc'
1019
+ else
1020
+ 'asc'
1021
+ end
1001
1022
  opts = {
1002
- age: options[:a],
1023
+ after: options[:after],
1024
+ age: options[:age],
1025
+ before: options[:before],
1003
1026
  count: options[:c].to_i,
1004
1027
  date_filter: dates,
1005
1028
  highlight: true,
1006
1029
  only_timed: options[:only_timed],
1007
1030
  order: options[:s],
1008
1031
  output: options[:output],
1032
+ search: options[:search],
1009
1033
  section: section,
1010
1034
  sort_tags: options[:sort_tags],
1011
1035
  tag_filter: tag_filter,
1036
+ tag_order: tag_order,
1012
1037
  tags_color: tags_color,
1013
1038
  times: options[:t],
1014
1039
  totals: options[:totals]
@@ -1030,6 +1055,14 @@ command [:grep, :search] do |c|
1030
1055
  c.arg_name 'NAME'
1031
1056
  c.flag %i[s section], default_value: 'All'
1032
1057
 
1058
+ c.desc 'Constrain search to entries older than date'
1059
+ c.arg_name 'DATE_STRING'
1060
+ c.flag [:before]
1061
+
1062
+ c.desc 'Constrain search to entries newer than date'
1063
+ c.arg_name 'DATE_STRING'
1064
+ c.flag [:after]
1065
+
1033
1066
  c.desc 'Output to export format (csv|html|json|template|timeline)'
1034
1067
  c.arg_name 'FORMAT'
1035
1068
  c.flag %i[o output], must_match: /^(?:template|html|csv|json|timeline)$/i
@@ -1054,10 +1087,12 @@ command [:grep, :search] do |c|
1054
1087
 
1055
1088
  section = wwid.guess_section(options[:s]) if options[:s]
1056
1089
 
1057
- options[:t] = true if options[:totals]
1090
+ options[:times] = true if options[:totals]
1058
1091
  options[:sort_tags] = options[:tag_sort] =~ /^n/i
1059
1092
 
1060
1093
  opts = {
1094
+ after: options[:after],
1095
+ before: options[:before],
1061
1096
  highlight: true,
1062
1097
  only_timed: options[:only_timed],
1063
1098
  output: options[:output],
@@ -1065,7 +1100,7 @@ command [:grep, :search] do |c|
1065
1100
  section: section,
1066
1101
  sort_tags: options[:sort_tags],
1067
1102
  tags_color: tags_color,
1068
- times: options[:t],
1103
+ times: options[:times],
1069
1104
  totals: options[:totals]
1070
1105
  }
1071
1106
 
@@ -1142,12 +1177,25 @@ command :today do |c|
1142
1177
  c.arg_name 'FORMAT'
1143
1178
  c.flag %i[o output], must_match: /^(?:template|html|csv|json|timeline)$/i
1144
1179
 
1180
+ c.desc 'View entries before specified time (e.g. 8am, 12:30pm, 15:00)'
1181
+ c.arg_name 'TIME_STRING'
1182
+ c.flag [:before]
1183
+
1184
+ c.desc 'View entries after specified time (e.g. 8am, 12:30pm, 15:00)'
1185
+ c.arg_name 'TIME_STRING'
1186
+ c.flag [:after]
1187
+
1145
1188
  c.action do |_global_options, options, _args|
1146
1189
  options[:t] = true if options[:totals]
1147
1190
  options[:sort_tags] = options[:tag_sort] =~ /^n/i
1148
-
1149
- puts wwid.today(options[:t], options[:output],
1150
- { totals: options[:totals], section: options[:s], sort_tags: options[:sort_tags] }).chomp
1191
+ opt = {
1192
+ after: options[:after],
1193
+ before: options[:before],
1194
+ section: options[:section],
1195
+ sort_tags: options[:sort_tags],
1196
+ totals: options[:totals]
1197
+ }
1198
+ puts wwid.today(options[:times], options[:output], opt).chomp
1151
1199
  end
1152
1200
  end
1153
1201
 
@@ -1381,7 +1429,7 @@ command :colors do |c|
1381
1429
  end
1382
1430
 
1383
1431
  desc 'Display a user-created view'
1384
- long_desc 'Command line options override associated view settings'
1432
+ long_desc 'Command line options override view configuration'
1385
1433
  arg_name 'VIEW_NAME'
1386
1434
  command :view do |c|
1387
1435
  c.desc 'Section'
@@ -1405,6 +1453,18 @@ command :view do |c|
1405
1453
  c.desc 'Include colors in output'
1406
1454
  c.switch [:color], default_value: true, negatable: true
1407
1455
 
1456
+ c.desc 'Tag filter, combine multiple tags with a comma.'
1457
+ c.arg_name 'TAG'
1458
+ c.flag [:tag]
1459
+
1460
+ c.desc 'Tag boolean (AND,OR,NOT)'
1461
+ c.arg_name 'BOOLEAN'
1462
+ c.flag %i[b bool], must_match: /(?:and|all|any|or|not|none)/i, default_value: 'OR'
1463
+
1464
+ c.desc 'Search filter, surround with slashes for regex (/query/)'
1465
+ c.arg_name 'QUERY'
1466
+ c.flag [:search]
1467
+
1408
1468
  c.desc 'Sort tags by (name|time)'
1409
1469
  c.arg_name 'KEY'
1410
1470
  c.flag [:tag_sort], must_match: /^(?:name|time)$/i
@@ -1413,10 +1473,20 @@ command :view do |c|
1413
1473
  c.arg_name 'DIRECTION'
1414
1474
  c.flag [:tag_order], must_match: /^(?:a(?:sc)?|d(?:esc)?)$/i
1415
1475
 
1476
+ c.desc 'View entries older than date'
1477
+ c.arg_name 'DATE_STRING'
1478
+ c.flag [:before]
1479
+
1480
+ c.desc 'View entries newer than date'
1481
+ c.arg_name 'DATE_STRING'
1482
+ c.flag [:after]
1483
+
1416
1484
  c.desc 'Only show items with recorded time intervals (override view settings)'
1417
1485
  c.switch [:only_timed], default_value: false, negatable: false
1418
1486
 
1419
1487
  c.action do |_global_options, options, args|
1488
+ exit_now! '--tag and --search cannot be used together' if options[:tag] && options[:search]
1489
+
1420
1490
  title = if args.empty?
1421
1491
  wwid.choose_view
1422
1492
  else
@@ -1441,7 +1511,11 @@ command :view do |c|
1441
1511
  format = view.key?('date_format') ? view['date_format'] : nil
1442
1512
  tags_color = view.key?('tags_color') ? view['tags_color'] : nil
1443
1513
  tag_filter = false
1444
- if view.key?('tags') && !(view['tags'].nil? || view['tags'].empty?)
1514
+ if options[:tag]
1515
+ tag_filter = { 'tags' => [], 'bool' => 'OR' }
1516
+ tag_filter['tags'] = options[:tag].gsub(/[, ]+/, ' ').split(' ').map(&:strip)
1517
+ tag_filter['bool'] = options[:bool].normalize_bool
1518
+ elsif view.key?('tags') && !(view['tags'].nil? || view['tags'].empty?)
1445
1519
  tag_filter = { 'tags' => [], 'bool' => 'OR' }
1446
1520
  tag_filter['tags'] = if view['tags'].instance_of?(Array)
1447
1521
  view['tags'].map(&:strip)
@@ -1490,14 +1564,17 @@ command :view do |c|
1490
1564
  else
1491
1565
  'asc'
1492
1566
  end
1493
- warn "TAG ORDER: #{options[:tag_order]}"
1567
+
1494
1568
  opts = {
1569
+ after: options[:after],
1570
+ before: options[:before],
1495
1571
  count: count,
1496
1572
  format: format,
1497
1573
  highlight: options[:color],
1498
1574
  only_timed: only_timed,
1499
1575
  order: order,
1500
- output: options[:o],
1576
+ output: options[:output],
1577
+ search: options[:search],
1501
1578
  section: section,
1502
1579
  sort_tags: options[:sort_tags],
1503
1580
  tag_filter: tag_filter,
data/lib/doing/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Doing
2
- VERSION = '1.0.86'
2
+ VERSION = '1.0.87'
3
3
  end
data/lib/doing/wwid.rb CHANGED
@@ -1742,6 +1742,24 @@ class WWID
1742
1742
  end
1743
1743
  end
1744
1744
 
1745
+ if opt[:before]
1746
+ time_string = opt[:before]
1747
+ time_string += ' 12am' if time_string !~ /(\d+:\d+|\d+[ap])/
1748
+ cutoff = chronify(time_string)
1749
+ if cutoff
1750
+ items.delete_if { |item| item['date'] >= cutoff }
1751
+ end
1752
+ end
1753
+
1754
+ if opt[:after]
1755
+ time_string = opt[:after]
1756
+ time_string += ' 11:59pm' if time_string !~ /(\d+:\d+|\d+[ap])/
1757
+ cutoff = chronify(time_string)
1758
+ if cutoff
1759
+ items.delete_if { |item| item['date'] <= cutoff }
1760
+ end
1761
+ end
1762
+
1745
1763
  if opt[:today]
1746
1764
  items.delete_if do |item|
1747
1765
  item['date'] < Date.today.to_time
@@ -1969,13 +1987,13 @@ class WWID
1969
1987
 
1970
1988
  output.sub!(/%shortdate/) do
1971
1989
  if item['date'] > Date.today.to_time
1972
- item['date'].strftime('%_I:%M%P')
1973
- elsif item['date'] > (Date.today - 7).to_time
1974
- item['date'].strftime('%a %-I:%M%P')
1990
+ item['date'].strftime(' %_I:%M%P')
1991
+ elsif item['date'] > (Date.today - 6).to_time
1992
+ item['date'].strftime('%a %_I:%M%P')
1975
1993
  elsif item['date'].year == Date.today.year
1976
- item['date'].strftime('%b %d, %-I:%M%P')
1994
+ item['date'].strftime('%m/%d %_I:%M%P')
1977
1995
  else
1978
- item['date'].strftime('%b %d %Y, %-I:%M%P')
1996
+ item['date'].strftime('%m/%d/%Y %_I:%M%P')
1979
1997
  end
1980
1998
  end
1981
1999
 
@@ -2189,8 +2207,22 @@ class WWID
2189
2207
  opt[:sort_tags] ||= false
2190
2208
 
2191
2209
  cfg = @config['templates']['today']
2192
- list_section({ section: opt[:section], wrap_width: cfg['wrap_width'], count: 0,
2193
- format: cfg['date_format'], template: cfg['template'], order: 'asc', today: true, times: times, output: output, totals: opt[:totals], sort_tags: opt[:sort_tags] })
2210
+ options = {
2211
+ after: opt[:after],
2212
+ before: opt[:before],
2213
+ count: 0,
2214
+ format: cfg['date_format'],
2215
+ order: 'asc',
2216
+ output: output,
2217
+ section: opt[:section],
2218
+ sort_tags: opt[:sort_tags],
2219
+ template: cfg['template'],
2220
+ times: times,
2221
+ today: true,
2222
+ totals: opt[:totals],
2223
+ wrap_width: cfg['wrap_width']
2224
+ }
2225
+ list_section(options)
2194
2226
  end
2195
2227
 
2196
2228
  ##
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.86
4
+ version: 1.0.87
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra