xuuki-do-list 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52201be4d5a2317a6eb1add43aa43dae5a4d8e0af639643f653b133e5be93162
4
- data.tar.gz: 85a6d79f5e9f2a4c8113bbc29c06352d0224b9b2c5e235d10c028625ad040669
3
+ metadata.gz: 0daa6a403e1d6ab8c83720f52ed1d1e4b4b79bb3fe4bc56c20be356b4b25e2f8
4
+ data.tar.gz: ed4a888b57548ae616b85818edab6246ae1473c0e0570ea27832ff24512d0f21
5
5
  SHA512:
6
- metadata.gz: 9b7e55f63ab771cf835fe8a60c106152e212d68bee89f52749f75fa2a7ae0f19a1e115679fd5fc98aa91a592104d70b243982aabdae9af045d72e61a04690ab8
7
- data.tar.gz: d833f02e20b9934dcee7bd085cadb4603b0eeadd8f3b368491530cddcd9eb95baf40123b1f700643aea5c4f9e259f1d5e62cab9c1a783725d2de56f3b6d20c5d
6
+ metadata.gz: bd54c3957ae40151b68111bc590bb120467bee4ec23a1685d4d729d09578a3b8e6c724e8abf4862829b192c92db031134632662773a7c6afceb0005fdceaab67
7
+ data.tar.gz: f7b090ae9ed6e589427121828ecf4d5969e21939d576f995c3f6834419de757086efce1ad70b39ad65d07791d67bb3270857f31392136ebe12ffcf5ad883d3d0
data/Rakefile CHANGED
@@ -2,6 +2,7 @@ require 'rake/clean'
2
2
  require 'rubygems'
3
3
  require 'rubygems/package_task'
4
4
  require 'rdoc/task'
5
+
5
6
  Rake::RDocTask.new do |rd|
6
7
  rd.main = "README.rdoc"
7
8
  rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
data/bin/xuuki-do-list CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'gli'
3
- # begin # XXX: Remove this begin/rescue before distributing your app
4
3
  require 'xuuki-do-list'
5
4
 
6
5
  require 'rubygems'
@@ -10,13 +9,14 @@ TODO_FILE = File.expand_path('~/todo.txt')
10
9
 
11
10
  class App
12
11
  extend GLI::App
12
+ config_file File.join(ENV['HOME'],'.xuuki-do-list.rc.yaml')
13
13
 
14
14
  program_desc 'Manage tasks in a todo list'
15
15
 
16
16
  version XuukiToDo::VERSION
17
17
 
18
18
  subcommand_option_handling :normal
19
- arguments :strict
19
+ # arguments :strict
20
20
 
21
21
  desc 'Path to the todo file'
22
22
  default_value '~/.todo.txt'
@@ -39,6 +39,7 @@ class App
39
39
  """
40
40
 
41
41
  arg_name 'task_name'
42
+
42
43
  command :new do |c|
43
44
  c.desc 'set the priority of the new task, 1 being the highest'
44
45
  c.arg_name 'priority'
@@ -54,12 +55,13 @@ class App
54
55
  puts "Command:"
55
56
  puts "-f - #{options[:f] ? 'true' : 'false'}"
56
57
  puts "-p - #{options[:p]}"
57
- puts "args - #{args.join(',')}"
58
+ puts "args - #{args.join(' ')}"
59
+ todo_file = File.expand_path(global_options[:f] || TODO_FILE)
58
60
 
59
61
  # Your command logic here
60
62
  new_task = ARGV.shift
61
63
 
62
- File.open(TODO_FILE,'a') do |file|
64
+ File.open(todo_file,'a') do |file|
63
65
  write_todo(file,new_task)
64
66
  puts "Task added."
65
67
  end
@@ -69,15 +71,36 @@ class App
69
71
  desc 'List tasks'
70
72
  arg_name 'Describe arguments to list here'
71
73
  command :list do |c|
74
+ c.desc 'Format of the output'
75
+ c.arg_name 'csv|pretty'
76
+ c.default_value 'pretty'
77
+ c.flag :format
78
+
72
79
  c.action do |global_options, options, args|
73
- File.open(TODO_FILE,'r') do |file|
80
+ puts "Global:"
81
+ puts "-f - #{global_options[:f]}"
82
+ puts "Command:"
83
+ puts "-f - #{options[:f] ? 'true' : 'false'}"
84
+ puts "-p - #{options[:p]}"
85
+ puts "args - #{args.join(' ')}"
86
+ todo_file = File.expand_path(global_options[:f] || TODO_FILE)
87
+
88
+ File.open(todo_file,'r') do |file|
74
89
  counter = 1
90
+
75
91
  file.readlines.each do |line|
76
92
  name,created,completed = read_todo(line)
77
- printf("%3d - %s\n",counter,name)
78
- printf(" Created : %s\n",created)
79
- unless completed.nil?
80
- printf(" Completed : %s\n",completed)
93
+ status = completed.nil? || completed.empty? ? "INCOMPLETE" : "DONE"
94
+
95
+ if options[:format] == 'pretty'
96
+ # Use the pretty-print format
97
+ printf("%3d - %s\n", counter, name)
98
+ printf(" Created : %s\n", created)
99
+ printf(" Status : %s\n", status)
100
+ printf(" Completed : %s\n", completed) unless completed.nil? || completed.empty?
101
+ elsif options[:format] == 'csv'
102
+ # Use the machine-readable CSV format
103
+ printf("%d,%s,%s,%s,%s\n", counter, name, status, created,completed)
81
104
  end
82
105
  counter += 1
83
106
  end
@@ -91,11 +114,16 @@ class App
91
114
  c.action do |global_options,options,args|
92
115
  puts "Global:"
93
116
  puts "-f - #{global_options[:f]}"
117
+ puts "Command:"
118
+ puts "-f - #{options[:f] ? 'true' : 'false'}"
119
+ puts "-p - #{options[:p]}"
120
+ puts "args - #{args.join(' ')}"
121
+ todo_file = File.expand_path(global_options[:f] || TODO_FILE)
94
122
 
95
123
  task_number = ARGV.shift.to_i
96
- if File.exist?(TODO_FILE)
97
- File.open(TODO_FILE, 'r') do |file|
98
- File.open("#{TODO_FILE}.new", 'w') do |new_file|
124
+ if File.exist?(todo_file)
125
+ File.open(todo_file, 'r') do |file|
126
+ File.open("#{todo_file}.new", 'w') do |new_file|
99
127
  counter = 1
100
128
  file.readlines.each do |line|
101
129
  name, created, completed = line.chomp.split(/,/)
@@ -109,14 +137,10 @@ class App
109
137
  end
110
138
  end
111
139
  end
112
- `mv #{TODO_FILE}.new #{TODO_FILE}`
140
+ `mv #{todo_file}.new #{todo_file}`
113
141
  else
114
- puts "No such file: #{TODO_FILE}"
142
+ puts "No such file: #{todo_file}"
115
143
  end
116
-
117
-
118
-
119
-
120
144
  end
121
145
  end
122
146