diff --git a/CHANGELOG.md b/CHANGELOG.md index 70a8ae36..dfe14827 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### 1.0.88 + +- Add --before and --after time search to yesterday command +- Add --before and --after date search to search/grep command +- Add --tag_order to yesterday command + ### 1.0.87 - Add leading spaces to make %shortdate align properly, at least for the last week diff --git a/README.md b/README.md index 403c5e0e..1305ab9f 100644 --- a/README.md +++ b/README.md @@ -545,6 +545,8 @@ If you have a use for it, you can use `-o csv` on the show or view commands to o `doing yesterday` is great for stand-ups (thanks to [Sean Collins](https://github.com/sc68cal) for that!). Note that you can show yesterday's activity from an alternate section by using the section name as an argument (e.g. `doing yesterday archive`). +All of the display commands (view, show, today, yesterday, search) support date ranges in addition to other filtering options. Results can be narrowed to a date/time span using `--before DATE` and `--after DATE`. The `DATE` accepts a natural language string but works best in formats like `10/20/21` or `2021-05-13 3pm` (or shortened to just `5/13 3pm`). For the `today` and `yesterday` commands the `DATE` should just be a time, e.g. `12pm` or `15:00`, and results will be filtered within the timespan for just that day. Both flags are optional, and you can use just `--before` to get everything older than a certain date, or use just `--after` to get everything newer. + `doing on` allows for full date ranges and filtering. `doing on saturday`, or `doing on one month to today` will give you ranges. You can use the same terms with the `show` command by adding the `-f` or `--from` flag. `doing show @done --from "monday to friday"` will give you all of your completed items for the last week (assuming it's the weekend). There's also `doing since` a simple alias for `doing on PAST_DATE to now`, e.g. `doing since monday`. You can also show entries matching a search string with `doing grep` (synonym `doing search`). If you want to search with regular expressions or for an exact match, surround your search query with forward slashes, e.g. `doing search /project name/`. If you pass a search string without slashes, it's treated as a fuzzy search string, meaning matches can be found as long as the characters in the search string are in order and with no more than three other characters between each. By default searches are across all sections, but you can limit it to one with the `-s SECTION_NAME` flag. Searches can be displayed with the default template, or output as HTML, CSV, or JSON. diff --git a/bin/doing b/bin/doing index 2b0f3fdc..a69edc57 100755 --- a/bin/doing +++ b/bin/doing @@ -1324,10 +1324,33 @@ command :yesterday do |c| c.arg_name 'KEY' c.flag [:tag_sort], must_match: /^(?:name|time)$/i, default_value: default + c.desc 'View entries before specified time (e.g. 8am, 12:30pm, 15:00)' + c.arg_name 'TIME_STRING' + c.flag [:before] + + c.desc 'View entries after specified time (e.g. 8am, 12:30pm, 15:00)' + c.arg_name 'TIME_STRING' + c.flag [:after] + + c.desc 'Tag sort direction (asc|desc)' + c.arg_name 'DIRECTION' + c.flag [:tag_order], must_match: /^(?:a(?:sc)?|d(?:esc)?)$/i + c.action do |_global_options, options, _args| + tag_order = if options[:tag_order] + options[:tag_order] =~ /^d/i ? 'desc' : 'asc' + else + 'asc' + end options[:sort_tags] = options[:tag_sort] =~ /^n/i - puts wwid.yesterday(options[:s], options[:t], options[:o], - { totals: options[:totals], sort_tags: options[:sort_tags] }).chomp + opt = { + after: options[:after], + before: options[:before], + sort_tags: options[:sort_tags], + tag_order: options[:tag_order], + totals: options[:totals] + } + puts wwid.yesterday(options[:section], options[:times], options[:output], opt).chomp end end diff --git a/lib/doing/version.rb b/lib/doing/version.rb index 2d60a087..7ba47e04 100644 --- a/lib/doing/version.rb +++ b/lib/doing/version.rb @@ -1,3 +1,3 @@ module Doing - VERSION = '1.0.87' + VERSION = '1.0.88' end diff --git a/lib/doing/wwid.rb b/lib/doing/wwid.rb index e8cc2754..f689b49a 100755 --- a/lib/doing/wwid.rb +++ b/lib/doing/wwid.rb @@ -2257,8 +2257,25 @@ def yesterday(section, times = nil, output = nil, opt = {}) opt[:totals] ||= false opt[:sort_tags] ||= false section = guess_section(section) - list_section({ section: section, count: 0, order: 'asc', yesterday: true, times: times, - output: output, totals: opt[:totals], sort_tags: opt[:sort_tags] }) + y = (Time.now - (60 * 60 * 24)).strftime('%Y-%m-%d') + opt[:after] = "#{y} #{opt[:after]}" if opt[:after] + opt[:before] = "#{y} #{opt[:before]}" if opt[:before] + + options = { + after: opt[:after], + before: opt[:before], + count: 0, + order: 'asc', + output: output, + section: section, + sort_tags: opt[:sort_tags], + tag_order: opt[:tag_order], + times: times, + totals: opt[:totals], + yesterday: true + } + + list_section(options) end ##