Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Introduce due-feature.

  • Loading branch information...
commit 1a9920814d92db79910c291fe315cb1f5ecc801e 1 parent 2880952
Bèr Kessels authored
Showing with 37 additions and 8 deletions.
  1. +26 −4 features/due.feature
  2. +11 −4 lib/todotxt/cli.rb
View
30 features/due.feature
@@ -12,16 +12,38 @@ Feature: Due
When I run `todotxt due` interactively
Then it should pass with todays date
- Scenario: List todays due
+ Scenario: List due items
Given the date is "2012-12-12"
- Given a todofile with the following items exists:
+ And a todofile with the following items exists:
| todo |
- | 2013-01-01 Install todotxt @cli +todotxt |
+ | 2012-12-17 Install todotxt @cli +todotxt |
| Read documentation +todotxt |
| 2012-12-12 Buy GTD book @amazon +wishlist |
+ | 2012-12-19 Evaluate installation +todotxt |
When I run `todotxt due` interactively
- Then it should pass with:
+ Then it should pass with exactly:
"""
Due today (2012-12-12)
3. 2012-12-12 Buy GTD book @amazon +wishlist
+
+ Past-due items
+
+ Due 7 days in advance
+ 1. 2012-12-17 Install todotxt @cli +todotxt
+ 4. 2012-12-19 Evaluate installation +todotxt
+
+ """
+
+ Scenario: list overdue items
+ Given the date is "2012-12-12"
+ And a todofile with the following items exists:
+ | todo |
+ | 2012-12-17 Install todotxt @cli +todotxt |
+ | Read documentation +todotxt |
+ | 2012-11-11 Buy GTD book @amazon +wishlist |
+ When I run `todotxt due` interactively
+ Then it should pass with:
+ """
+ Past-due items
+ 3. 2012-11-11 Buy GTD book @amazon +wishlist
"""
View
15 lib/todotxt/cli.rb
@@ -1,5 +1,6 @@
require "thor"
require "rainbow"
+require "chronic"
require "parseconfig"
module Todotxt
@@ -74,13 +75,19 @@ def lscon
desc "due", "List due items"
def due
if ENV["date"] # Allow testing to "freeze" the date
- today = DateTime.parse(ENV["date"]).strftime("%Y-%m-%d")
+ today = DateTime.parse(ENV["date"]).to_date
else
- today = DateTime.now.strftime("%Y-%m-%d")
+ today = DateTime.now.to_date
end
- puts "Due today (#{today})"
- @list.filter(today).each { |todo| puts format_todo(todo) }
+ puts "Due today (#{today.strftime("%Y-%m-%d")})"
+ @list.on_date(today).each { |todo| puts format_todo(todo) }
+ puts "\nPast-due items"
+ @list.before_date(today).each { |todo| puts format_todo(todo) }
+ puts "\nDue 7 days in advance"
+ ((today+1)..(today+7)).each do |day|
+ @list.on_date(day).each { |todo| puts format_todo(todo) }
+ end
end
#
Please sign in to comment.
Something went wrong with that request. Please try again.