xuuki-do-list 0.0.2 → 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 +24 -10
- 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
|
@@ -75,8 +77,15 @@ class App
|
|
75
77
|
c.flag :format
|
76
78
|
|
77
79
|
c.action do |global_options, options, args|
|
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)
|
78
87
|
|
79
|
-
File.open(
|
88
|
+
File.open(todo_file,'r') do |file|
|
80
89
|
counter = 1
|
81
90
|
|
82
91
|
file.readlines.each do |line|
|
@@ -105,11 +114,16 @@ class App
|
|
105
114
|
c.action do |global_options,options,args|
|
106
115
|
puts "Global:"
|
107
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)
|
108
122
|
|
109
123
|
task_number = ARGV.shift.to_i
|
110
|
-
if File.exist?(
|
111
|
-
File.open(
|
112
|
-
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|
|
113
127
|
counter = 1
|
114
128
|
file.readlines.each do |line|
|
115
129
|
name, created, completed = line.chomp.split(/,/)
|
@@ -123,9 +137,9 @@ class App
|
|
123
137
|
end
|
124
138
|
end
|
125
139
|
end
|
126
|
-
`mv #{
|
140
|
+
`mv #{todo_file}.new #{todo_file}`
|
127
141
|
else
|
128
|
-
puts "No such file: #{
|
142
|
+
puts "No such file: #{todo_file}"
|
129
143
|
end
|
130
144
|
end
|
131
145
|
end
|