Browse code
Adding a pretty-printer that fixes certain errors
Right now, it'll automagically handle whitespace errors and certain
errors in the format of the time.
Showing 2 changed files
... | ... |
@@ -32,7 +32,14 @@ |
32 | 32 |
(format stream "~@d~a" amount unit))) |
33 | 33 |
(:method ((token date-obj) &optional stream) |
34 | 34 |
(with-slots (day-of-week year month day) token |
35 |
- (format stream "~a ~2,'0d-~2,'0d-~2,'0d" day-of-week year month day))) |
|
35 |
+ (let ((day-of-week (format nil "~aday" |
|
36 |
+ (string-case (string-downcase day-of-week) |
|
37 |
+ ("tue" (setf day-of-week "Tues")) |
|
38 |
+ ("wed" (setf day-of-week "Wednes")) |
|
39 |
+ ("thu" (setf day-of-week "Thurs")) |
|
40 |
+ ("sat" (setf day-of-week "Satur")) |
|
41 |
+ (t (string-capitalize day-of-week)))))) |
|
42 |
+ (format stream "~a ~2,'0d-~2,'0d-~2,'0d" day-of-week year month day)))) |
|
36 | 43 |
(:method ((token time-obj) &optional stream) |
37 | 44 |
(with-slots (hour minute second) token |
38 | 45 |
(format stream "~2,'0d:~2,'0d:~2,'0d" hour minute second))) |
... | ... |
@@ -181,6 +181,10 @@ |
181 | 181 |
:description "The kind of output to produce" |
182 | 182 |
:default-value :normal |
183 | 183 |
:enum '(:xunit :normal))) |
184 |
+ (group (:header "Reformat options") |
|
185 |
+ (flag :long-name "reformat-file" |
|
186 |
+ :short-name "f" |
|
187 |
+ :description "Read the current timesheet file and dump, correcting any whitespace or formatting errors")) |
|
184 | 188 |
(group (:header "Generic options") |
185 | 189 |
(flag :short-name "v" :long-name "version" |
186 | 190 |
:description "Show the program version") |
... | ... |
@@ -201,6 +205,13 @@ |
201 | 205 |
(:xunit (should-test:test-for-xunit *standard-output* :package :tempores.parser)) |
202 | 206 |
(:normal (should-test:test :package :tempores.parser))))) |
203 | 207 |
|
208 |
+(defun reformat-main () |
|
209 |
+ (with-tempores-configuration () |
|
210 |
+ (format t "~{~a~}" |
|
211 |
+ (mapcar #'unparse |
|
212 |
+ (parse-file *default-time-sheet-file* |
|
213 |
+ t))))) |
|
214 |
+ |
|
204 | 215 |
(defun pprint-log-main () |
205 | 216 |
(make-context) |
206 | 217 |
(tagbody |
... | ... |
@@ -216,6 +227,7 @@ |
216 | 227 |
do (plump:serialize item) |
217 | 228 |
finally (format t "Don't forget to archive time file.")))) |
218 | 229 |
((getopt :long-name "run-tests") (tests-main (getopt :long-name "output-style"))) |
230 |
+ ((getopt :long-name "reformat-file") (reformat-main)) |
|
219 | 231 |
(t (with-tempores-configuration () |
220 | 232 |
(pprint-log |
221 | 233 |
(remainder) |