Skip to content

Commit

Permalink
release prep
Browse files Browse the repository at this point in the history
  • Loading branch information
ttscoff committed Aug 1, 2021
1 parent 6932d56 commit e2fbaf3
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 1.0.69

- Add `--unfinished` option to finish and cancel commands

### 1.0.68

- Fix error in `doing show --sort` argument parsing
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ _Side note:_ I actually use the library behind this utility as part of another s

## Installation

The current version of `doing` is <!--VER-->1.0.67<!--END VER-->.
The current version of `doing` is <!--VER-->1.0.68<!--END VER-->.

$ [sudo] gem install doing

Expand Down Expand Up @@ -464,6 +464,7 @@ You can also include a `--no-date` switch to add `@done` without a finish date,

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.

Both `finish` and `cancel` accept `--unfinished` as an argument. This causes them to act on the last entry not already marked @done, no matter how far back it's dated or how many @done entries come after it. You can use `doing finish --unfinished X -s SECTION` to finish the last X unfinished entries in SECTION.

##### Tagging and Autotagging

Expand Down
28 changes: 24 additions & 4 deletions bin/doing
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ command :cancel do |c|
c.arg_name 'BOOLEAN'
c.flag [:bool], must_match: /(?:and|all|any|or|not|none)/i, default_value: 'AND'

c.desc 'Cancel last entry (or entries) not already marked @done'
c.switch %i[u unfinished], negatable: false, default_value: false

c.action do |_global_options, options, args|
section = wwid.guess_section(options[:s]) || options[:s].cap_first

Expand Down Expand Up @@ -478,7 +481,8 @@ command :cancel do |c|
sequential: false,
tag: tags,
tag_bool: options[:bool],
tags: ['done']
tags: ['done'],
unfinished: options[:unfinished]
}
wwid.tag_last(opts)
end
Expand Down Expand Up @@ -512,6 +516,9 @@ command :finish do |c|
c.arg_name 'BOOLEAN'
c.flag [:bool], must_match: /(?:and|all|any|or|not|none)/i, default_value: 'AND'

c.desc 'Finish last entry (or entries) not already marked @done'
c.switch %i[u unfinished], negatable: false, default_value: false

c.desc %(Auto-generate finish dates from next entry's start time.
Automatically generate completion dates 1 minute before next start date.
--auto overrides the --date and --back parameters.)
Expand Down Expand Up @@ -574,7 +581,8 @@ command :finish do |c|
sequential: options[:auto],
tag: tags,
tag_bool: options[:bool],
tags: ['done']
tags: ['done'],
unfinished: options[:unfinished]
}
wwid.tag_last(opts)
end
Expand Down Expand Up @@ -648,6 +656,9 @@ command :tag do |c|
c.desc 'Remove given tag(s)'
c.switch %i[r remove], negatable: false, default_value: false

c.desc 'Tag last entry (or entries) not marked @done'
c.switch %i[u unfinished], negatable: false, default_value: false

c.desc 'Autotag entries based on autotag configuration in ~/.doingrc'
c.switch %i[a autotag], negatable: false, default_value: false

Expand Down Expand Up @@ -691,7 +702,8 @@ command :tag do |c|
date: options[:date],
remove: options[:r],
section: section,
tags: tags
tags: tags,
unfinished: options[:unfinished]
}
wwid.tag_last(opts)
end
Expand All @@ -706,9 +718,17 @@ command [:mark, :flag] do |c|
c.desc 'Remove mark'
c.switch %i[r remove], negatable: false, default_value: false

c.desc 'Mark last entry not marked @done'
c.switch %i[u unfinished], negatable: false, default_value: false

c.action do |_global_options, options, _args|
mark = wwid.config['marker_tag'] || 'flagged'
wwid.tag_last({ tags: [mark], section: options[:s], remove: options[:r] })
wwid.tag_last({
remove: options[:r],
section: options[:s],
tags: [mark],
unfinished: options[:unfinished]
})
end
end

Expand Down
1 change: 1 addition & 0 deletions lib/doing/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def has_tags?(tags, bool = :and)
tags = tags.split(/ *, */) if tags.is_a? String
bool = bool.normalize_bool if bool.is_a? String
item = self
tags.map! {|t| t.strip.sub(/^@/, '')}
case bool
when :and
result = true
Expand Down
2 changes: 1 addition & 1 deletion lib/doing/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Doing
VERSION = '1.0.68'
VERSION = '1.0.69'
end
4 changes: 3 additions & 1 deletion lib/doing/wwid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ def tag_last(opt = {})
opt[:autotag] ||= false
opt[:back] ||= false
opt[:took] ||= nil
opt[:unfinished] ||= false

sec_arr = []

Expand Down Expand Up @@ -816,10 +817,11 @@ def tag_last(opt = {})
items.map! do |item|
break if idx == count

finished = opt[:unfinished] && item.has_tags?('done', :and)
tag_match = opt[:tag].nil? || opt[:tag].empty? ? true : item.has_tags?(opt[:tag], opt[:tag_bool])
search_match = opt[:search].nil? || opt[:search].empty? ? true : item.matches_search?(opt[:search])

if tag_match && search_match
if tag_match && search_match && !finished
if opt[:autotag]
new_title = autotag(item['title']) if @auto_tag
if new_title == item['title']
Expand Down
7 changes: 7 additions & 0 deletions test/doing_done_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ def test_finish_tag
assert_no_match(ENTRY_DONE_REGEX, t2, "@tag2 entry should not have @done timestamp")
end

def test_finish_unfinished
doing('now', '--back=15m', 'Adding an unfinished entry')
doing('done', 'Adding a finished entry')
result = doing('--stdout', 'finish', '--unfinished')
assert_match(/Added @done: "Adding an unfinished entry/, result, "Earlier unfinished task should be marked @done")
end

def test_finish_took
subject = 'Test new entry @tag1'
doing('now', subject)
Expand Down

0 comments on commit e2fbaf3

Please sign in to comment.