gwtf 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,7 +22,7 @@ module Gwtf
22
22
  def self.projects(root_dir)
23
23
  Dir.entries(root_dir).map do |entry|
24
24
  next if entry =~ /^\./
25
- next unless File.directory?(File.join(root_dir, entry))
25
+ next unless File.directory?(File.join(root_dir, entry))
26
26
 
27
27
  entry
28
28
  end.compact.sort
@@ -22,6 +22,8 @@ command [:list, :ls, :l] do |c|
22
22
  longest_name = projects.map{|p| p.length}.max
23
23
 
24
24
  projects.each_with_index do |project, idx|
25
+ next if project == "reminders"
26
+
25
27
  puts "Items in all projects:\n\n" if idx == 0
26
28
 
27
29
  items = Gwtf::Items.new(File.join(global_options[:data], project), project)
@@ -43,6 +45,8 @@ command [:list, :ls, :l] do |c|
43
45
 
44
46
  elsif options[:due]
45
47
  Gwtf.projects(global_options[:data]).each do |project|
48
+ next if project == "reminders"
49
+
46
50
  items = Gwtf::Items.new(File.join(global_options[:data], project), project)
47
51
 
48
52
  items.each_item do |item|
@@ -52,6 +56,8 @@ command [:list, :ls, :l] do |c|
52
56
 
53
57
  elsif options[:overview]
54
58
  Gwtf.projects(global_options[:data]).each do |project|
59
+ next if project == "reminders"
60
+
55
61
  items = Gwtf::Items.new(File.join(global_options[:data], project), project)
56
62
 
57
63
  if items.item_ids.size > 0
@@ -1,13 +1,12 @@
1
- desc 'Send a reminder about an item via email'
2
- arg_name 'id [at time specification]'
1
+ desc 'Manage or send reminders about an item'
3
2
  long_desc <<EOF
4
- When run without the --send option this comand will
5
- add an at() job using the supplied at time specification.
3
+ Schedule a reminder for an existing task: gwtf remind 10 now +5 minutes
6
4
 
7
- The at job will call the same command again this time
8
- with the --send option that will send an email to you
9
- or the address specified in --recipient using your system
10
- mail command
5
+ Send a reminder for an existing task immediately: gwtf remind 10 --send
6
+
7
+ Add a new item to the reminders project and schedule a reminder: gwtf remind --at="noon tomorrow" have lunch
8
+
9
+ Time specifications are in at(1) format.
11
10
  EOF
12
11
 
13
12
  command [:remind, :rem] do |c|
@@ -27,17 +26,44 @@ command [:remind, :rem] do |c|
27
26
  c.default_value false
28
27
  c.switch [:ifopen]
29
28
 
29
+ c.desc "at(1) time specification for the reminder to be sent"
30
+ c.default_value nil
31
+ c.flag [:at]
32
+
30
33
  c.action do |global_options,options,args|
31
34
  raise "Please supply an item ID to remind about" if args.empty?
32
35
 
36
+ STDOUT.sync
37
+
33
38
  unless options[:send]
34
- raise "Please specify a valid at() time specification" unless args.size > 2
39
+ if args.first =~ /^\d+$/ # got an item id, schedule a reminder
40
+ unless options[:at]
41
+ raise "Please specify a valid at(1) time specification with --at after the item id" unless args.size > 2
42
+ options[:at] = args[1..-1].join(" ")
43
+ end
44
+
45
+ print "Creating reminder at job for item #{args.first}: "
35
46
 
36
- STDOUT.sync
47
+ @items.load_item(args.first).schedule_reminer(options[:at], options[:recipient], options[:done], options[:ifopen])
37
48
 
38
- print "Creating reminder at job for item #{args.first}: "
49
+ else # new reminder in the 'reminders' project
50
+ raise "Please specify an at(1) time specification" unless options[:at]
51
+ raise "Please specify a subject for the reminder item" if args.empty?
39
52
 
40
- @items.load_item(args.first).schedule_reminer(args[1..-1].join(" "), options[:recipient], options[:done], options[:ifopen])
53
+ project_dir = File.join(global_options[:data], "reminders")
54
+ Gwtf::Items.setup(project_dir) unless File.directory?(project_dir)
55
+
56
+ items = Gwtf::Items.new(project_dir, "reminders")
57
+ reminder = items.new_item
58
+ reminder.subject = args.join(" ")
59
+
60
+ print "Creating reminder at job for item #{reminder.item_id}: "
61
+ reminder.schedule_reminer(options[:at], options[:recipient], true, true)
62
+
63
+ reminder.save
64
+
65
+ puts reminder.to_s
66
+ end
41
67
  else
42
68
  item = @items.load_item(args.first)
43
69
 
@@ -1,3 +1,3 @@
1
1
  module Gwtf
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.0'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gwtf
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 5
8
+ - 6
9
9
  - 0
10
- version: 0.5.0
10
+ version: 0.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - R.I.Pienaar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-08 00:00:00 +01:00
18
+ date: 2012-04-09 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency