pday 0.4 → 0.5
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.
- data/lib/pday.rb +30 -9
- metadata +1 -1
data/lib/pday.rb
CHANGED
|
@@ -99,40 +99,61 @@ main do
|
|
|
99
99
|
filepath=options['path']+entrydate+suffix+'.'+options['format']
|
|
100
100
|
if File.file?(filepath)
|
|
101
101
|
unless options[:force]
|
|
102
|
-
|
|
102
|
+
if options[:verbose]
|
|
103
|
+
puts "File already exists. Will use existing file."
|
|
104
|
+
end
|
|
103
105
|
else
|
|
104
|
-
|
|
106
|
+
if options[:verbose]
|
|
107
|
+
puts "File already exists, replacing it."
|
|
108
|
+
end
|
|
105
109
|
`echo '#{prepopulate(entrydate)}' > "#{filepath}"`
|
|
106
110
|
end
|
|
107
111
|
else
|
|
108
|
-
|
|
112
|
+
if options[:verbose]
|
|
113
|
+
puts "Creating new entry for: "+entrydate
|
|
114
|
+
end
|
|
109
115
|
`echo '#{prepopulate(entrydate)}' > "#{filepath}"`
|
|
110
116
|
end
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
if !options[:log]
|
|
118
|
+
if !options[:output]
|
|
119
|
+
if options[:verbose]
|
|
120
|
+
puts "Editing entry: #{filepath}"
|
|
121
|
+
end
|
|
122
|
+
exec("#{options['editor']} '#{filepath}'")
|
|
123
|
+
else
|
|
124
|
+
exec("cat #{filepath}")
|
|
125
|
+
end
|
|
114
126
|
else
|
|
115
127
|
# THE LOG OPTION IS ON SO JUST APPEND A LINE
|
|
116
128
|
if options['log']!=''
|
|
117
|
-
|
|
129
|
+
if options[:verbose]
|
|
130
|
+
puts "Adding log entry to: #{filepath}"
|
|
131
|
+
end
|
|
118
132
|
if options[:timestamp]
|
|
119
133
|
options['log']=Time.new.strftime("%H:%M")+" "+options['log']
|
|
120
134
|
end
|
|
121
|
-
|
|
135
|
+
if options[:output]
|
|
136
|
+
addoutput="; cat #{filepath}"
|
|
137
|
+
else
|
|
138
|
+
addoutput=""
|
|
139
|
+
end
|
|
140
|
+
exec("echo '#{formatlog(options['log'])}' >> #{filepath}#{addoutput}")
|
|
122
141
|
end
|
|
123
142
|
end
|
|
124
143
|
end
|
|
125
144
|
|
|
126
|
-
version '0.
|
|
145
|
+
version '0.5'
|
|
127
146
|
description 'Simple plain text diary management script.'
|
|
128
147
|
|
|
129
148
|
on("-t FORMAT","--format","Set format suffix")
|
|
149
|
+
on("-o","--output","Output the log file instead of opening it")
|
|
130
150
|
on("-f","--force","Replace any existing file instead of editing it")
|
|
131
151
|
on("-s SUFFIX","--suffix","Add suffix to file name (before format suffix)")
|
|
132
152
|
on("-e EDITOR","--editor","Set the editor, vim, emacs, nano, etc.")
|
|
133
153
|
on("-d DATE","--date","Supply an explicit date (also y, yy, yyy, t) ")
|
|
134
154
|
on("-l LOG","--log","Instead of opening file, add a single log line")
|
|
135
155
|
on("-p","--timestamp","Add timestamp to single line log")
|
|
156
|
+
on("-v","--verbose","Show more information when executing")
|
|
136
157
|
|
|
137
158
|
|
|
138
159
|
go!
|