Skip to content

Commit

Permalink
Remove --case option, sticking with smart case
Browse files Browse the repository at this point in the history
  • Loading branch information
ttscoff committed Nov 18, 2021
1 parent ed2451b commit eb7afb1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 55 deletions.
51 changes: 0 additions & 51 deletions bin/doing
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,6 @@ command %i[reset begin] do |c|
c.desc 'Force exact search string matching (case sensitive)'
c.switch %i[x exact], default_value: false, negatable: false

c.desc 'Force case sensitive search string matching'
c.switch %i[case]

c.desc 'Reset items that *don\'t* match search/tag filters'
c.switch [:not], default_value: false, negatable: false

Expand All @@ -221,7 +218,6 @@ command %i[reset begin] do |c|
if options[:search]
search = options[:search]
search.sub!(/^'?/, "'") if options[:exact]
search.downcase! if options[:case] == false
options[:search] = search
end

Expand Down Expand Up @@ -286,9 +282,6 @@ command :note do |c|
c.desc 'Force exact search string matching (case sensitive)'
c.switch %i[x exact], default_value: false, negatable: false

c.desc 'Force case sensitive search string matching'
c.switch %i[case]

c.desc 'Add note to item that *doesn\'t* match search/tag filters'
c.switch [:not], default_value: false, negatable: false

Expand All @@ -309,7 +302,6 @@ command :note do |c|
if options[:search]
search = options[:search]
search.sub!(/^'?/, "'") if options[:exact]
search.downcase! if options[:case] == false
options[:search] = search
end

Expand Down Expand Up @@ -510,9 +502,6 @@ command :select do |c|
c.desc 'Force exact search string matching (case sensitive)'
c.switch %i[x exact], default_value: false, negatable: false

c.desc 'Force case sensitive search string matching'
c.switch %i[case]

c.desc 'Select items that *don\'t* match search/tag filters'
c.switch [:not], default_value: false, negatable: false

Expand Down Expand Up @@ -890,9 +879,6 @@ command :finish do |c|
c.desc 'Force exact search string matching (case sensitive)'
c.switch %i[x exact], default_value: false, negatable: false

c.desc 'Force case sensitive search string matching'
c.switch %i[case]

c.desc 'Finish items that *don\'t* match search/tag filters'
c.switch [:not], default_value: false, negatable: false

Expand Down Expand Up @@ -969,7 +955,6 @@ command :finish do |c|
if options[:search]
search = options[:search]
search.sub!(/^'?/, "'") if options[:exact]
search.downcase! if options[:case] == false
end

opts = {
Expand Down Expand Up @@ -1015,9 +1000,6 @@ command %i[again resume] do |c|
c.desc 'Force exact search string matching (case sensitive)'
c.switch %i[x exact], default_value: false, negatable: false

c.desc 'Force case sensitive search string matching'
c.switch %i[case]

c.desc 'Resume items that *don\'t* match search/tag filters'
c.switch [:not], default_value: false, negatable: false

Expand All @@ -1041,7 +1023,6 @@ command %i[again resume] do |c|
if options[:search]
search = options[:search]
search.sub!(/^'?/, "'") if options[:exact]
search.downcase! if options[:case] == false
options[:search] = search
end

Expand Down Expand Up @@ -1119,9 +1100,6 @@ command :tag do |c|
c.desc 'Force exact search string matching (case sensitive)'
c.switch %i[x exact], default_value: false, negatable: false

c.desc 'Force case sensitive search string matching'
c.switch %i[case]

c.desc 'Tag items that *don\'t* match search/tag filters'
c.switch [:not], default_value: false, negatable: false

Expand Down Expand Up @@ -1172,7 +1150,6 @@ command :tag do |c|
if options[:search]
search = options[:search]
search.sub!(/^'?/, "'") if options[:exact]
search.downcase! if options[:case] == false
options[:search] = search
end

Expand Down Expand Up @@ -1249,9 +1226,6 @@ command [:mark, :flag] do |c|
c.desc 'Force exact search string matching (case sensitive)'
c.switch %i[x exact], default_value: false, negatable: false

c.desc 'Force case sensitive search string matching'
c.switch %i[case]

c.desc 'Flag items that *don\'t* match search/tag/date filters'
c.switch [:not], default_value: false, negatable: false

Expand Down Expand Up @@ -1289,7 +1263,6 @@ command [:mark, :flag] do |c|
if options[:search]
search = options[:search]
search.sub!(/^'?/, "'") if options[:exact]
search.downcase! if options[:case] == false
options[:search] = search
end

Expand Down Expand Up @@ -1370,9 +1343,6 @@ command :show do |c|
c.desc 'Force exact search string matching (case sensitive)'
c.switch %i[x exact], default_value: false, negatable: false

c.desc 'Force case sensitive search string matching'
c.switch %i[case]

c.desc 'Show items that *don\'t* match search/tag/date filters'
c.switch [:not], default_value: false, negatable: false

Expand Down Expand Up @@ -1483,7 +1453,6 @@ command :show do |c|
if options[:search]
search = options[:search]
search.sub!(/^'?/, "'") if options[:exact]
search.downcase! if options[:case] == false
options[:search] = search
end

Expand Down Expand Up @@ -1569,7 +1538,6 @@ command %i[grep search] do |c|
section = wwid.guess_section(options[:section]) if options[:section]
search = args.join(' ')
search.sub!(/^'?/, "'") if options[:exact]
search.downcase! if options[:case] == false

options[:times] = true if options[:totals]
options[:sort_tags] = options[:tag_sort] =~ /^n/i
Expand Down Expand Up @@ -1895,9 +1863,6 @@ command :last do |c|
c.desc 'Force exact search string matching (case sensitive)'
c.switch %i[x exact], default_value: false, negatable: false

c.desc 'Force case sensitive search string matching'
c.switch %i[case]

c.desc 'Show items that *don\'t* match search string or tag filter'
c.switch [:not], default_value: false, negatable: false

Expand All @@ -1924,7 +1889,6 @@ command :last do |c|
if options[:search]
search = options[:search]
search.sub!(/^'?/, "'") if options[:exact]
search.downcase! if options[:case] == false
end

if options[:editor]
Expand Down Expand Up @@ -2092,9 +2056,6 @@ command :view do |c|
c.desc 'Force exact search string matching (case sensitive)'
c.switch %i[x exact], default_value: false, negatable: false

c.desc 'Force case sensitive search string matching'
c.switch %i[case]

c.desc 'Show items that *don\'t* match search string'
c.switch [:not], default_value: false, negatable: false

Expand Down Expand Up @@ -2234,7 +2195,6 @@ command :view do |c|
if options[:search]
search = options[:search]
search.sub!(/^'?/, "'") if options[:exact]
search.downcase! if options[:case] == false
end

opts = options
Expand Down Expand Up @@ -2314,9 +2274,6 @@ command %i[archive move] do |c|
c.desc 'Force exact search string matching (case sensitive)'
c.switch %i[x exact], default_value: false, negatable: false

c.desc 'Force case sensitive search string matching'
c.switch %i[case]

c.desc 'Show items that *don\'t* match search string'
c.switch [:not], default_value: false, negatable: false

Expand Down Expand Up @@ -2348,7 +2305,6 @@ command %i[archive move] do |c|
if options[:search]
search = options[:search]
search.sub!(/^'?/, "'") if options[:exact]
search.downcase! if options[:case] == false
end

opts = options
Expand Down Expand Up @@ -2390,9 +2346,6 @@ command :rotate do |c|
c.desc 'Force exact search string matching (case sensitive)'
c.switch %i[x exact], default_value: false, negatable: false

c.desc 'Force case sensitive search string matching'
c.switch %i[case]

c.desc 'Rotate items that *don\'t* match search string or tag filter'
c.switch [:not], default_value: false, negatable: false

Expand All @@ -2413,7 +2366,6 @@ command :rotate do |c|
if options[:search]
search = options[:search]
search.sub!(/^'?/, "'") if options[:exact]
search.downcase! if options[:case] == false
options[:search] = search
end

Expand Down Expand Up @@ -2608,9 +2560,6 @@ command :import do |c|
c.desc 'Force exact search string matching (case sensitive)'
c.switch %i[x exact], default_value: false, negatable: false

c.desc 'Force case sensitive search string matching'
c.switch %i[case]

c.desc 'Import items that *don\'t* match search/tag/date filters'
c.switch [:not], default_value: false, negatable: false

Expand Down
2 changes: 1 addition & 1 deletion lib/doing/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def initialize(msg = '')
end

class WrongCommand < ::StandardError
def initialize(msg = 'wrong command', topic = 'Error:')
def initialize(msg = 'wrong command', topic: 'Error:')
Doing.logger.warn(topic, msg)

super(msg)
Expand Down
2 changes: 1 addition & 1 deletion lib/doing/wwid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def dedup(items, no_overlap = false)
duped = no_overlap ? item.overlapping_time?(comp) : item.same_time?(comp)
break if duped
end
logger.count(:skipped, level: :debug, message: 'overlapping %item') if duped
logger.count(:skipped, level: :debug, message: '%count overlapping %items') if duped
# logger.log_now(:debug, 'Skipped:', "overlapping entry: #{item.title}") if duped
duped
end
Expand Down
4 changes: 2 additions & 2 deletions test/doing_import_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_timing_import
result = doing('--stdout', '--debug', 'import', '--type', 'timing', @timing_import_file)
assert_match(/Imported: #{target} items/, result, "Should have imported #{target} entries")
result = doing('--stdout', '--debug', 'import', '--type', 'timing', @timing_import_file)
assert_match(/Skipped: #{target} items/, result, "Should have skipped #{target} duplicate entries")
assert_match(/Skipped: #{target} overlapping items/, result, "Should have skipped #{target} duplicate entries")
end

def test_timing_import_no_arg
Expand Down Expand Up @@ -66,7 +66,7 @@ def test_timing_import_no_overlap
target = json.count
doing('done', '--back', '2021-07-22 11:20', '--took', '30m', 'Testing overlapping entry')
result = doing('--stdout', '--debug', 'import', '--type', 'timing', '--no-overlap', @timing_import_file)
assert_match(/Skipped: 1 items/, result, "Should have skipped #{target} duplicate entries")
assert_match(/Skipped: 1 overlapping item/, result, "Should have skipped #{target} duplicate entries")
assert_match(/Imported: #{target - 1} items/, result, "Should have imported #{target - 1} entries")
end

Expand Down

0 comments on commit eb7afb1

Please sign in to comment.