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 +4 -4
- data/Rakefile +1 -0
- data/bin/xuuki-do-list +42 -18
- data/doc/Build Awesome Command-Line Applications in Ruby.txt +10336 -0
- data/lib/xuuki-do-list/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0daa6a403e1d6ab8c83720f52ed1d1e4b4b79bb3fe4bc56c20be356b4b25e2f8
|
4
|
+
data.tar.gz: ed4a888b57548ae616b85818edab6246ae1473c0e0570ea27832ff24512d0f21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd54c3957ae40151b68111bc590bb120467bee4ec23a1685d4d729d09578a3b8e6c724e8abf4862829b192c92db031134632662773a7c6afceb0005fdceaab67
|
7
|
+
data.tar.gz: f7b090ae9ed6e589427121828ecf4d5969e21939d576f995c3f6834419de757086efce1ad70b39ad65d07791d67bb3270857f31392136ebe12ffcf5ad883d3d0
|
data/Rakefile
CHANGED
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(
|
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
|
-
|
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
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
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?(
|
97
|
-
File.open(
|
98
|
-
File.open("#{
|
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 #{
|
140
|
+
`mv #{todo_file}.new #{todo_file}`
|
113
141
|
else
|
114
|
-
puts "No such file: #{
|
142
|
+
puts "No such file: #{todo_file}"
|
115
143
|
end
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
144
|
end
|
121
145
|
end
|
122
146
|
|