pomo 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.md CHANGED
@@ -1,4 +1,22 @@
1
1
 
2
+ 0.0.4 / 2009-10-15
3
+ ==================
4
+
5
+ * Added / implemented selection api via Pomo::List#find
6
+
7
+ 0.0.3 / 2009-10-15
8
+ ==================
9
+
10
+ * Added --complete switch for `pomo list`
11
+ * Added --incomplete switch for `pomo list`
12
+ * Changed INT message; more user-friendly
13
+
14
+ 0.0.2 / 2009-10-15
15
+ ==================
16
+
17
+ * Added `pomo remove all`
18
+ * Added `pomo complete`
19
+
2
20
  0.0.1 / 2009-10-15
3
21
  ==================
4
22
 
data/Readme.md CHANGED
@@ -38,12 +38,22 @@ Once you have completed the task, list again:
38
38
  √ 0. Fix IE stying issues : 25 minutes
39
39
  1. Destroy IE : 25 minutes
40
40
 
41
+ List only remaining tasks:
42
+ $ pomo list --incomplete
43
+ 1. Destroy IE : 25 minutes
44
+
45
+ List only completed tasks:
46
+ $ pomo list --complete
47
+ √ 0. Fix IE stying issues : 25 minutes
48
+
41
49
  At any time mid-task you may terminate pomo via CTRL + C, at which time
42
50
  you may manually complete the task:
43
51
  $ pomo complete first
44
52
  $ pomo complete last
45
53
  $ pomo complete 1
46
- $ pomo complete 5
54
+ $ pomo complete all
55
+ $ pomo complete incomplete
56
+ $ pomo complete 5..7
47
57
 
48
58
  The next time you run `pomo start` the first incomplete task will start:
49
59
  $ pomo start
@@ -60,17 +70,37 @@ You may also remove tasks
60
70
  $ pomo remove 1
61
71
  $ pomo remove 6
62
72
  $ pomo rm first
63
- $ pomo rm last
73
+ $ pomo rm 2..5
74
+ $ pomo rm 1..-1
64
75
 
65
76
  View task details:
66
77
  $ pomo view first
67
78
  $ pomo view last
68
79
  $ pomo view 5
69
- $ pomo view 1
80
+ $ pomo view 1 2 3
70
81
 
71
82
  Remove all tasks:
72
83
  $ pomo remove all
73
84
  $ pomo rm all
85
+
86
+ ## Task Selection API
87
+
88
+ Taken from `pomo help`:
89
+
90
+ Most of the subcommands work directly with tasks,
91
+ and because of this pomo provides a unified task selection api
92
+ shown below which can be used with most of the commands
93
+ (those with [task ...] in their synopsis).
94
+
95
+ n : selects a single task by index : Ex: pomo remove 1
96
+ [n ]+ : selects several tasks by index : Ex: pomo remove 2 8 1
97
+ n..n : selects a range of tasks : Ex: pomo remove 5..9
98
+ n..-n : selects a range of tasks : Ex: pomo remove 2..-1
99
+ first : selects the first task : Ex: pomo remove first
100
+ last : selects the last task : Ex: pomo remove last
101
+ complete : selects complete tasks : Ex: pomo remove complete
102
+ incomplete : selects incomplete tasks : Ex: pomo remove incomplete
103
+ all : selects all tasks : Ex: pomo remove all
74
104
 
75
105
  ## License
76
106
 
data/bin/pomo CHANGED
@@ -6,32 +6,47 @@ require 'commander/import'
6
6
  require 'pomo'
7
7
 
8
8
  program :version, Pomo::VERSION
9
- program :description, 'Pomodoro time management'
9
+ program :description, "Pomodoro time management.
10
+ Most of the subcommands work directly with tasks, and
11
+ because of this pomo provides a unified task selection api
12
+ shown below which can be used with most of the commands
13
+ (those with [task ...] in their synopsis).
14
+
15
+ n : selects a single task by index : Ex: pomo remove 1
16
+ [n ]+ : selects several tasks by index : Ex: pomo remove 2 8 1
17
+ n..n : selects a range of tasks : Ex: pomo remove 5..9
18
+ n..-n : selects a range of tasks : Ex: pomo remove 2..-1
19
+ first : selects the first task : Ex: pomo remove first
20
+ last : selects the last task : Ex: pomo remove last
21
+ complete : selects complete tasks : Ex: pomo remove complete
22
+ incomplete : selects incomplete tasks : Ex: pomo remove incomplete
23
+ all : selects all tasks : Ex: pomo remove all
24
+ "
25
+
10
26
  program :int_message, "\nTerminated pomo" \
11
27
  "\n * previously running tasks not marked as complete" \
12
28
  "\n * manually complete a task with `$ pomo complete <task>`"
13
29
 
14
30
  list = Pomo::List.new '~/.pomo'
15
-
31
+
16
32
  command :start do |c|
17
- c.syntax = 'pomo start [number] [options]'
33
+ c.syntax = 'pomo start [task] [options]'
18
34
  c.summary = 'Start a task'
19
- c.description = 'Start a task, given the task [number] or the first task'
35
+ c.description = 'Start a task, given the task [task] or the first task'
20
36
  c.example 'Start the first task', 'pomo start'
21
37
  c.example 'Start the first task', 'pomo start 0'
22
38
  c.example 'Start the first task', 'pomo start first'
23
39
  c.example 'Start the fifth task', 'pomo start 5'
24
40
  c.action do |args, options|
25
- if task = list.tasks.at(args.first ? args.first.to_i : 0)
41
+ list.find(*args) do |task, i|
26
42
  abort 'task already completed' if task.complete?
27
43
  say "Started #{task}, you have #{task.length} minutes :)"
28
44
  task.start
29
45
  list.save
46
+ break
30
47
  end
31
48
  end
32
49
  end
33
- alias_command :'start first', :start, '0'
34
- alias_command :'start last', :start, list.tasks.length - 1
35
50
 
36
51
  command :add do |c|
37
52
  c.syntax = 'pomo add <task> [options]'
@@ -50,74 +65,60 @@ command :add do |c|
50
65
  end
51
66
 
52
67
  command :remove do |c|
53
- c.syntax = 'pomo [remove|rm] <number> [options]'
68
+ c.syntax = 'pomo [remove|rm] [task ...] [options]'
54
69
  c.summary = 'Remove a task'
55
- c.description = 'Remove a task, given the task <number>'
70
+ c.description = 'Remove a task, given the task(s) or the first task'
56
71
  c.example 'Remove the first task', 'pomo remove first'
57
72
  c.example 'Remove the last task', 'pomo remove last'
58
73
  c.example 'Remove the fifth task', 'pomo remove 5'
59
- c.example 'Remove the fifth task', 'pomo rm 5'
74
+ c.example 'Remove the fifth and second task', 'pomo rm 5 2'
75
+ c.example 'Remove a range of tasks', 'pomo rm 2..6'
76
+ c.example 'Remove all but the first task', 'pomo rm 2..-1'
77
+ c.example 'Remove all tasks', 'pomo rm all'
60
78
  c.action do |args, options|
61
- list.tasks.each_with_index do |task, i|
62
- if i == args.first.to_i
63
- list.tasks.delete_at i
64
- say "Removed #{task}"
65
- end
66
- end
79
+ list.find(*args) do |task, i|
80
+ list.tasks -= [task]
81
+ say "Removed #{task}"
82
+ end
67
83
  list.save
68
84
  end
69
85
  end
70
86
  alias_command :rm, :remove
71
- alias_command :'remove first', :remove, '0'
72
- alias_command :'remove last', :remove, list.tasks.length - 1
73
-
74
- command :'remove all' do |c|
75
- c.syntax = 'pomo remove all'
76
- c.description = 'Remove all tasks'
77
- c.action do
78
- list.tasks = []
79
- list.save
80
- say "Tasks removed"
81
- end
82
- end
83
- alias_command :'rm all', :'remove all'
84
87
 
85
88
  command :view do |c|
86
- c.syntax = 'pomo view [number] [options]'
89
+ c.syntax = 'pomo view [task ...] [options]'
87
90
  c.summary = 'View a task'
88
- c.description = 'View verbose information for the given task [number] or the first task'
91
+ c.description = 'View verbose information for the given task(s) or the first task'
89
92
  c.example 'View the first task', 'pomo view first'
90
93
  c.example 'View the last task', 'pomo view last'
91
94
  c.example 'View the fifth task', 'pomo view 5'
92
95
  c.action do |args, options|
93
- if task = list.tasks.at(args.first ? args.first.to_i : 0)
96
+ list.find(*args) do |task, i|
97
+ say "\n"
94
98
  format = "%15s : %s\n"
95
99
  say format % ['name', task.name]
96
100
  say format % ['length', "#{task.length} minutes"]
97
101
  say format % ['description', task.description || '...']
98
102
  end
103
+ say "\n"
99
104
  end
100
105
  end
101
- alias_command :'view first', :view, '0'
102
- alias_command :'view last', :view, list.tasks.length - 1
103
106
 
104
107
  command :complete do |c|
105
- c.syntax = 'pomo complete [number] [options]'
108
+ c.syntax = 'pomo complete [task ...] [options]'
106
109
  c.summary = 'Mark a task as completed'
107
- c.description = 'Mark the given task [number] or the first task to complete'
110
+ c.description = 'Mark the given task(s) or the first task to complete'
108
111
  c.example 'Mark first task as complete', 'pomo complete first'
109
112
  c.example 'Mark last task as complete', 'pomo complete last'
110
113
  c.example 'Mark fifth task as complete', 'pomo complete 5'
111
114
  c.action do |args, options|
112
- if task = list.tasks.at(args.first ? args.first.to_i : 0)
115
+ list.find(*args) do |task, i|
113
116
  task.complete = true
114
- list.save
115
117
  say "Completed #{task}"
116
118
  end
119
+ list.save
117
120
  end
118
121
  end
119
- alias_command :'complete first', :complete, '0'
120
- alias_command :'complete last', :complete, list.tasks.length - 1
121
122
 
122
123
  command :list do |c|
123
124
  c.syntax = 'pomo list [options]'
@@ -126,11 +127,11 @@ command :list do |c|
126
127
  c.option '-c', '--complete', 'List only completed tasks'
127
128
  c.option '-i', '--incomplete', 'List only incompleted tasks'
128
129
  c.action do |args, options|
129
- list.tasks.each_with_index do |task, i|
130
- next if options.complete && !task.complete?
131
- next if options.incomplete && task.complete?
132
- say ' %s %2d. %-35s : %d minutes' % [task.complete? ? '√' : ' ', i, task.to_s, task.length]
133
- end
130
+ list.tasks.each_with_index do |task, i|
131
+ next if options.complete && !task.complete?
132
+ next if options.incomplete && task.complete?
133
+ say ' %s %2d. %-35s : %d minutes' % [task.complete? ? '√' : ' ', i, task.to_s, task.length]
134
+ end
134
135
  end
135
136
  end
136
137
 
data/lib/pomo/list.rb CHANGED
@@ -21,6 +21,47 @@ module Pomo
21
21
  load rescue save
22
22
  end
23
23
 
24
+ ##
25
+ # Find tasks by _args_, iterating with _block_.
26
+ #
27
+ # Supports the following:
28
+ #
29
+ # * n
30
+ # * n n n
31
+ # * n..n
32
+ # * n..-n
33
+ # * first
34
+ # * last
35
+ # * incomplete
36
+ # * complete[d]
37
+ # * all
38
+ #
39
+
40
+ def find *args, &block
41
+ found = []
42
+ found << tasks.first if args.empty?
43
+ if args.include? 'all'
44
+ found = tasks
45
+ elsif args.include? 'first'
46
+ found << tasks.first
47
+ elsif args.include? 'last'
48
+ found << tasks.last
49
+ elsif args.include?('complete') || args.include?('completed')
50
+ found = tasks.select { |task| task.complete? }
51
+ elsif args.include? 'incomplete'
52
+ found = tasks.select { |task| not task.complete? }
53
+ elsif args.any? { |arg| arg =~ /(\d+)\.\.(-?\d+)/ }
54
+ found = tasks[$1.to_i..$2.to_i]
55
+ else
56
+ tasks.each_with_index do |task, i|
57
+ found << task if args.any? { |a| a.to_i == i }
58
+ end
59
+ end
60
+ found.each_with_index do |task, i|
61
+ yield task, i
62
+ end
63
+ end
64
+
24
65
  ##
25
66
  # Add _task_ to the list in memory (requires saving).
26
67
 
data/lib/pomo/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Pomo
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
data/pomo.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{pomo}
5
- s.version = "0.0.3"
5
+ s.version = "0.0.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["TJ Holowaychuk"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pomo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Holowaychuk