doing 1.0.59 → 1.0.63

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6829ecedb3ba583fcd4abde952d884e27ec239d2fe39a65e93ed19540b69fd21
4
- data.tar.gz: 9ae0b29ce7e6cc99f9efdbb17f5dfb4165543aa7da32a0a28c617c2b48bba682
3
+ metadata.gz: c103e507e82866174c88e6c3613f613964eaacba5f499631598b9ecbbb0cbe55
4
+ data.tar.gz: edb32425ba3e81c1e3ff5bfeed3d0cb0b2dd8c2a353bc3d6adee6b98bf3536e0
5
5
  SHA512:
6
- metadata.gz: bc0e8e23b484e76f23394c6cab610d483afb137f642d34cc6471071e69684c62f6c72e1e4eb7fda1370e6b85d57dcc03b2ec42cdd74c2593741e8d1e74a4932b
7
- data.tar.gz: 11417b5f85b9b0909686c3e778fa81018feeccd0fd49eef1f9f47f6e835fee7c6d510427c9edfef7066d1785128f3145fc475e66a39d3075051045eec33e13ff
6
+ metadata.gz: 20b03da63cba70b6c12a2f7775429f974fba8bc12b5f7c411d7a8e4a765f6c3113d3a627cf96684e4fbdb26c1b0430e0beec196cd0d2f655dd4459ba10b0902f
7
+ data.tar.gz: 934a87ead078f5fa7d2b7260921bfdeb15a57ecddd7a793003ad7dabb5dbf5bc093c1048258ffaba41e0ad00f5d49ab26cbdb825cca5e7f21c30446d92e3b10e
data/README.md CHANGED
@@ -29,7 +29,7 @@ _Side note:_ I actually use the library behind this utility as part of another s
29
29
 
30
30
  ## Installation
31
31
 
32
- The current version of `doing` is <!--VER-->1.0.58<!--END VER-->.
32
+ The current version of `doing` is <!--VER-->1.0.62<!--END VER-->.
33
33
 
34
34
  $ [sudo] gem install doing
35
35
 
@@ -167,7 +167,7 @@ The config also contains templates for various command outputs. Include placehol
167
167
  - there are some random special combo colors. Use `doing colors` to see the list
168
168
  - `%interval`: when used with the `-t` switch on the `show` command, it will display the time between a timestamp or _@start(date)_ tag and the _@done(date)_ tag, if it exists. Otherwise, it will remain empty.
169
169
 
170
- Date formats are based on Ruby [`strftime`](http://www.ruby-doc.org/stdlib-2.1.1/libdoc/date/rdoc/Date.html#method-i-strftime) formatting.
170
+ Date formats are based on Ruby [`strftime`](http://www.ruby-doc.org/stdlib-2.1.1/libdoc/date/rdoc/Date.html#method-i-strftime) formatting. You can try it out [here](http://strftime.net).
171
171
 
172
172
  My normal template for the `recent` command looks like this:
173
173
 
@@ -394,24 +394,41 @@ Note that you can include a tag with synonyms in the whitelist as well to tag it
394
394
 
395
395
  #### Adding entries:
396
396
 
397
- now, did - Add an entry
397
+ now, next - Add an entry
398
398
  later - Add an item to the Later section
399
- done - Add a completed item with @done(date). No argument finishes last entry.
399
+ done, did - Add a completed item with @done(date). No argument finishes last entry.
400
400
  meanwhile - Finish any @meanwhile tasks and optionally create a new one
401
401
  again, resume - Duplicate the last entry as new entry (without @done tag)
402
402
 
403
- The `doing now` command can accept `-s section_name` to send the new entry straight to a non-default section. It also accepts `--back=AMOUNT` to let you specify a start date in the past using "natural language." For example, `doing now --back=25m ENTRY` or `doing now --back="yesterday 3:30pm" ENTRY`.
403
+ ##### now
404
404
 
405
- If you want to use `--back` with `doing done` but want the end time to be different than the start time, you can either use `--took` in addition, or just use `--took` on its own as it will backdate the start time such that the end time is now and the duration is equal to the value of the `--took` argument.
405
+ The `doing now` command adds an entry to the "Currently" section by default. It accepts `-s section_name` to send the new entry straight to a non-default section. It also accepts `--back=AMOUNT` to let you specify a start date in the past using "natural language." For example, `doing now --back=25m ENTRY` or `doing now --back="yesterday 3:30pm" ENTRY`.
406
406
 
407
407
  You can finish the last unfinished task when starting a new one using `doing now` with the `-f` switch. It will look for the last task not marked _@done_ and add the _@done_ tag with the start time of the new task (either the current time or what you specified with `--back`).
408
408
 
409
- `doing done` is used to add an entry that you've already completed. Like `now`, you can specify a section with `-s section_name`. You can also skip straight to Archive with `-a`.
409
+ > __Examples:__
410
+ >
411
+ > - `doing now Working on project X` --- Add a new entry at the current time
412
+ > - `doing now --section=Projects Working on @projectX` --- Add a new entry to a section titled "Projects"
413
+ > - `doing now --back 30m` --- Add a new entry with a backdated start time, indicating you've been working on it for 30 minutes already
414
+ > - `doing now --back 8am` --- Backdate a new entry to a specific time
415
+ > - `doing now -f Starting the next thing` --- Add a new entry at the current time, and add a @done tag to the previous item with the current time as its completion date
416
+ > - `doing now -f --back 30m Working on something new` --- Add a new entry and complete the last entry, but use a timestamp from 30 minutes ago for both.
410
417
 
411
- `doing done` can also backdate entries using natural language with `--back 15m` or `--back "3/15 3pm"`. That will modify the starting timestamp of the entry. You can also use `--took 1h20m` or `--took 1:20` to set the finish date based on a "natural language" time interval. If `--took` is used without `--back`, then the start date is adjusted (`--took` interval is subtracted) so that the completion date is the current time.
418
+ ##### done/finish
419
+
420
+ `doing done` is used to add an entry that you've already completed. Like `now`, you can specify a section with `-s section_name`. You can also skip straight to the Archive with `-a`.
421
+
422
+ `doing done` can also backdate entries using natural language with `--back 15m` or `--back "3/15 3pm"`. That will modify the starting timestamp of the entry. Used on its own, it will set the start date, and the finish date will be the current time. You can also use `--took 1h20m` or `--took 1:20` to set the finish date based on a "natural language" time interval. If `--took` is used without `--back`, then the start date is adjusted (`--took` interval is subtracted) so that the completion date is the current time.
412
423
 
413
424
  When used with `doing done`, `--back` and `--took` allow time intervals to be accurately counted when entering items after the fact. `--took` is also available for the `doing finish` command, but cannot be used in conjunction with `--back`. (In `finish` they both set the end date, and neither has priority. `--back` allows specific days/times, `--took` uses time intervals.)
414
425
 
426
+ > __Examples:__
427
+ >
428
+ > - `doing done --back 1h The thing I just did` --- Add an entry for a completed task that you started an hour ago and just finished
429
+ > - `doing done --back 1h --took 20m The thing I just finished` --- Record an entry you started an hour ago and finished 20 minutes later
430
+ > - `doing done --took 20m` --- Finish the last task but change the finish date so that the total elapsed time is only 20 minutes (if the finish date would be in the future, start date will be adjusted accordingly)
431
+
415
432
  All of these commands accept a `-e` argument. This opens your command line editor (as defined in the environment variable `$EDITOR`). Add your entry, save the temp file, and close it. The new entry is added. Anything after the first line is included as a note on the entry.
416
433
 
417
434
  `doing again` (or `doing resume`) will duplicate the last @done entry (most recently completed) with a new start date (and without the @done tag). To resume the last entry matching specific tags, use `--tag=TAG`. You can specify multiple tags by separating with a comma. Multiple tags are combined with 'AND' by default (all tags must exist on the entry to match), but you can use `--bool=` to set it to 'OR' or 'NOT'. By default the new entry will be added to the same section as the matching entry, but you can specify a section with `--in=SECTION`.
@@ -429,7 +446,7 @@ See `doing help meanwhile` for more options.
429
446
 
430
447
  ##### Finishing
431
448
 
432
- `doing finish` by itself is the same as `doing done` by itself. It adds _@done(timestamp)_ to the last entry. It also accepts a numeric argument to complete X number of tasks back in history. Add `-a` to also archive the affected entries.
449
+ `doing finish` by itself is the same as `doing done` by itself. It adds _@done(timestamp)_ to the last entry. It also accepts a numeric argument to complete X number of tasks back in history (0 affects all entries). Add `-a` to also archive the affected entries.
433
450
 
434
451
  `doing finish` also provides an `--auto` flag, which you can use to set the end time of any entry to 1 minute before the start time of the next. Running a command such as `doing finish --auto 10` will go through the last 10 entries and sequentially update any without a _@done_ tag with one set to the time just before the next entry in the list.
435
452
 
@@ -445,6 +462,8 @@ You can change the boolean using `--bool=OR` (last entry containing any of the s
445
462
 
446
463
  You can also include a `--no-date` switch to add `@done` without a finish date, meaning no time is tracked for the task. `doing cancel` is an alias for this. Like `finish`, `cancel` accepts a count to act on the last X entries, as well as `--archive` and `--section` options. `cancel` also accepts the `--tag` and `--bool` flags for tag filtering.
447
464
 
465
+ By default `doing finish` works on a single entry, the last entry or the most recent entry matching a `--tag` or `--search` query. Specifying `doing finish 10` would finish any unfinished entries within the last 10 entries. In the case of `--tag` or `--search` queries, the count serves as the maximum number of matches doing will act on, sorted in reverse date order (most recent first). A count of 0 will disable the limit entirely, acting on all matching entries.
466
+
448
467
 
449
468
  ##### Tagging and Autotagging
450
469
 
data/bin/doing CHANGED
@@ -310,7 +310,7 @@ end
310
310
 
311
311
  desc 'Add a completed item with @done(date). No argument finishes last entry.'
312
312
  arg_name 'ENTRY'
313
- command [:done, :did] do |c|
313
+ command %i[done did] do |c|
314
314
  c.desc 'Remove @done tag'
315
315
  c.switch %i[r remove], negatable: false, default_value: false
316
316
 
@@ -367,15 +367,18 @@ command [:done, :did] do |c|
367
367
 
368
368
  date = options[:took] ? finish_date - took : finish_date
369
369
  elsif options[:took]
370
- finish_date = date + took
370
+ finish_date = options[:back] ? date + took : nil
371
371
  elsif options[:back]
372
372
  finish_date = date
373
373
  else
374
374
  finish_date = Time.now
375
375
  end
376
376
 
377
+ if finish_date
378
+ donedate = options[:date] ? "(#{finish_date.strftime('%F %R')})" : ''
379
+ end
380
+
377
381
  section = wwid.guess_section(options[:s]) || options[:s].cap_first
378
- donedate = options[:date] ? "(#{finish_date.strftime('%F %R')})" : ''
379
382
 
380
383
  if options[:e]
381
384
  raise 'No EDITOR variable defined in environment' if ENV['EDITOR'].nil?
@@ -394,8 +397,15 @@ command [:done, :did] do |c|
394
397
  if options[:r]
395
398
  wwid.tag_last({ tags: ['done'], count: 1, section: section, remove: true })
396
399
  else
397
- wwid.tag_last({ tags: ['done'], count: 1, section: section, archive: options[:a], back: finish_date,
398
- date: options[:date] })
400
+ options = { tags: ['done'],
401
+ archive: options[:a],
402
+ back: finish_date,
403
+ count: 1,
404
+ date: options[:date],
405
+ section: section,
406
+ took: took == 0 ? nil : took
407
+ }
408
+ wwid.tag_last(options)
399
409
  end
400
410
  elsif !args.empty?
401
411
  title, note = wwid.format_input(args.join(' '))
@@ -572,7 +582,7 @@ command [:again, :resume] do |c|
572
582
 
573
583
  c.desc 'Boolean used to combine multiple tags'
574
584
  c.arg_name 'BOOLEAN'
575
- c.flag [:bool], must_match: /^(and|or|not)$/i, default_value: 'ALL'
585
+ c.flag [:bool], must_match: /^(and|or|not)$/i, default_value: 'AND'
576
586
 
577
587
  c.desc 'Note'
578
588
  c.arg_name 'TEXT'
@@ -1230,14 +1240,17 @@ desc 'Move entries between sections'
1230
1240
  arg_name 'SECTION_NAME'
1231
1241
  default_value wwid.current_section
1232
1242
  command :archive do |c|
1233
- c.desc 'Count to keep (ignored if archiving by tag)'
1234
- c.arg_name 'COUNT'
1235
- c.flag %i[k keep], default_value: 5, must_match: /^\d+$/, type: Integer
1243
+ c.desc 'How many items to keep (ignored if archiving by tag or search)'
1244
+ c.arg_name 'X'
1245
+ c.flag %i[k keep], must_match: /^\d+$/, type: Integer
1236
1246
 
1237
1247
  c.desc 'Move entries to'
1238
1248
  c.arg_name 'SECTION_NAME'
1239
1249
  c.flag %i[t to], default_value: 'Archive'
1240
1250
 
1251
+ c.desc 'Label moved items with @from(SECTION_NAME)'
1252
+ c.switch [:label], default_value: true, negatable: true
1253
+
1241
1254
  c.desc 'Tag filter, combine multiple tags with a comma. Added for compatibility with other commands.'
1242
1255
  c.arg_name 'TAG'
1243
1256
  c.flag [:tag]
@@ -1246,21 +1259,36 @@ command :archive do |c|
1246
1259
  c.arg_name 'BOOLEAN'
1247
1260
  c.flag [:bool], must_match: /(and|or|not)/i, default_value: 'AND'
1248
1261
 
1262
+ c.desc 'Search filter'
1263
+ c.arg_name 'QUERY'
1264
+ c.flag [:search]
1265
+
1249
1266
  c.action do |_global_options, options, args|
1250
1267
  if args.empty?
1251
1268
  section = wwid.current_section
1252
1269
  tags = []
1270
+ elsif args[0] =~ /^all/i
1271
+ section = 'all'
1253
1272
  elsif args[0] =~ /^@\S+/
1254
1273
  section = 'all'
1255
1274
  tags = args.map { |t| t.sub(/^@/, '').strip }
1256
1275
  else
1257
1276
  section = args[0].cap_first
1258
- tags = args.length > 1 ? args[1..].map { |t| t.sub(/^@/, '').strip } : nil
1277
+ tags = args.length > 1 ? args[1..].map { |t| t.sub(/^@/, '').strip } : []
1259
1278
  end
1260
1279
 
1280
+ raise '--keep and --count can\'t be used together' if options[:keep] && options[:count]
1281
+
1261
1282
  tags.concat(options[:tag].split(/ *, */).map { |t| t.sub(/^@/, '').strip }) if options[:tag]
1262
1283
 
1263
- wwid.archive(section, options[:keep], options[:to], tags, options[:bool])
1284
+ opts = {
1285
+ bool: options[:bool],
1286
+ destination: options[:to],
1287
+ keep: options[:keep],
1288
+ search: options[:search],
1289
+ tags: tags
1290
+ }
1291
+ wwid.archive(section, opts)
1264
1292
  end
1265
1293
  end
1266
1294
 
data/lib/doing/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Doing
2
- VERSION = '1.0.59'
2
+ VERSION = '1.0.63'
3
3
  end
data/lib/doing/wwid.rb CHANGED
@@ -776,6 +776,7 @@ class WWID
776
776
  opt[:remove] ||= false
777
777
  opt[:autotag] ||= false
778
778
  opt[:back] ||= false
779
+ opt[:took] ||= nil
779
780
 
780
781
  sec_arr = []
781
782
 
@@ -833,6 +834,13 @@ class WWID
833
834
  else
834
835
  done_date = item['date'] + (opt[:back] - item['date'])
835
836
  end
837
+ elsif opt[:took]
838
+ if item['date'] + opt[:took] > Time.now
839
+ item['date'] = Time.now - opt[:took]
840
+ done_date = Time.now
841
+ else
842
+ done_date = item['date'] + opt[:took]
843
+ end
836
844
  else
837
845
  done_date = Time.now
838
846
  end
@@ -1551,31 +1559,24 @@ class WWID
1551
1559
  ## section
1552
1560
  ##
1553
1561
  ## @param section (String) The source section
1554
- ## @param count (Integer) The count
1555
- ## @param destination (String) The destination section
1556
- ## @param tags (Array) Tags to archive
1557
- ## @param bool (String) Tag boolean combinator
1562
+ ## @param options (Hash) Options
1558
1563
  ##
1559
- def archive(section = 'Currently', count = 5, destination = nil, tags = nil, bool = nil, _export = nil)
1564
+ def archive(section = 'Currently', options = {})
1565
+ count = options[:keep] || 0
1566
+ destination = options[:destination] || 'Archive'
1567
+ tags = options[:tags] || []
1568
+ bool = options[:bool] || 'AND'
1569
+
1560
1570
  section = choose_section if section.nil? || section =~ /choose/i
1561
- archive_all = section =~ /all/i # && !(tags.nil? || tags.empty?)
1571
+ archive_all = section =~ /^all$/i # && !(tags.nil? || tags.empty?)
1562
1572
  section = guess_section(section) unless archive_all
1563
1573
 
1564
- add_section('Archive') if destination =~ /archive/i && !sections.include?('Archive')
1574
+ add_section('Archive') if destination =~ /^archive$/i && !sections.include?('Archive')
1565
1575
 
1566
1576
  destination = guess_section(destination)
1567
1577
 
1568
1578
  if sections.include?(destination) && (sections.include?(section) || archive_all)
1569
- if archive_all
1570
- to_archive = sections.dup
1571
- to_archive.delete(destination)
1572
- to_archive.each do |source, _v|
1573
- do_archive(source, destination, { count: count, tags: tags, bool: bool, label: true })
1574
- end
1575
- else
1576
- do_archive(section, destination, { count: count, tags: tags, bool: bool, label: true })
1577
- end
1578
-
1579
+ do_archive(section, destination, { count: count, tags: tags, bool: bool, search: options[:search], label: options[:label] })
1579
1580
  write(doing_file)
1580
1581
  else
1581
1582
  raise 'Either source or destination does not exist'
@@ -1589,74 +1590,69 @@ class WWID
1589
1590
  ## @param destination (String) The destination section
1590
1591
  ## @param opt (Hash) Additional Options
1591
1592
  ##
1592
- def do_archive(section, destination, opt = {})
1593
- count = opt[:count] || 5
1594
- tags = opt[:tags] || []
1595
- bool = opt[:bool] || 'AND'
1596
- label = opt[:label] || false
1593
+ def do_archive(sect, destination, opt = {})
1594
+ count = opt[:count] || 0
1595
+ tags = opt[:tags] || []
1596
+ bool = opt[:bool] || 'AND'
1597
+ label = opt[:label] || true
1597
1598
 
1598
- items = @content[section]['items']
1599
- moved_items = []
1599
+ if sect =~ /^all$/i
1600
+ all_sections = sections.dup
1601
+ all_sections.delete(destination)
1602
+ else
1603
+ all_sections = [sect]
1604
+ end
1600
1605
 
1601
- if tags && !tags.empty?
1602
- items.delete_if do |item|
1603
- case bool
1604
- when /(AND|ALL)/i
1605
- score = 0
1606
- tags.each do |tag|
1607
- score += 1 if item['title'] =~ /@#{tag}/i
1608
- end
1609
- res = score < tags.length
1610
- moved_items.push(item) if res
1611
- res
1612
- when /NONE/i
1613
- del = false
1614
- tags.each do |tag|
1615
- del = true if item['title'] =~ /@#{tag}/i
1606
+ counter = 0
1607
+
1608
+ all_sections.each do |section|
1609
+ items = @content[section]['items']
1610
+
1611
+ moved_items = []
1612
+ if !tags.empty? || opt[:search]
1613
+ items.delete_if do |item|
1614
+ if (!tags.empty? && item.has_tags?(tags, bool) || (opt[:search] && item.matches_search?(opt[:search].to_s)))
1615
+ moved_items.push(item)
1616
+ counter += 1
1617
+ true
1618
+ else
1619
+ false
1616
1620
  end
1617
- moved_items.push(item) if del
1618
- del
1619
- when /(OR|ANY)/i
1620
- del = true
1621
- tags.each do |tag|
1622
- del = false if item['title'] =~ /@#{tag}/i
1621
+ end
1622
+ moved_items.each do |item|
1623
+ if label && section != 'Currently'
1624
+ item['title'] =
1625
+ item['title'].sub(/(?:@from\(.*?\))?(.*)$/, "\\1 @from(#{section})")
1623
1626
  end
1624
- moved_items.push(item) if del
1625
- del
1626
1627
  end
1627
- end
1628
- moved_items.each do |item|
1629
- if label && section != 'Currently'
1630
- item['title'] =
1631
- item['title'].sub(/(?:@from\(.*?\))?(.*)$/, "\\1 @from(#{section})")
1628
+
1629
+ @content[section]['items'] = items
1630
+ @content[destination]['items'].concat(moved_items)
1631
+ @results.push("Archived #{moved_items.length} items from #{section} to #{destination}")
1632
+ else
1633
+ count = items.length if count == 0 || items.length < count
1634
+
1635
+ @content[section]['items'] = if count.zero?
1636
+ []
1637
+ else
1638
+ items[0..count - 1]
1639
+ end
1640
+
1641
+ items.map! do |item|
1642
+ if label && section != 'Currently'
1643
+ item['title'] =
1644
+ item['title'].sub(/(?:@from\(.*?\))?(.*)$/, "\\1 @from(#{section})")
1645
+ end
1646
+ item
1632
1647
  end
1633
- end
1634
- @content[section]['items'] = moved_items
1635
- @content[destination]['items'] += items
1636
- @results.push("Archived #{items.length} items from #{section} to #{destination}")
1637
- else
1638
- count = items.length if items.length < count
1639
-
1640
- @content[section]['items'] = if count.zero?
1641
- []
1642
- else
1643
- items[0..count - 1]
1644
- end
1645
-
1646
- items.map! do |item|
1647
- if label && section != 'Currently'
1648
- item['title'] =
1649
- item['title'].sub(/(?:@from\(.*?\))?(.*)$/, "\\1 @from(#{section})")
1648
+ if items.count > count
1649
+ @content[destination]['items'].concat(items[count..-1])
1650
+ else
1651
+ @content[destination]['items'].concat(items)
1650
1652
  end
1651
- item
1652
- end
1653
- if items.count > count
1654
- @content[destination]['items'].concat(items[count..-1])
1655
- else
1656
- @content[destination]['items'].concat(items)
1657
- end
1658
1653
 
1659
- @results.push("Archived #{items.length - count} items from #{section} to #{destination}")
1654
+ @results.push("Archived #{items.length - count} items from #{section} to #{destination}")
1655
+ end
1660
1656
  end
1661
1657
  end
1662
1658
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.59
4
+ version: 1.0.63
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-07 00:00:00.000000000 Z
11
+ date: 2021-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake