File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99(import ./plan/parser :as plan_parser )
1010(import ./plan/serializer :as plan_serializer )
1111
12+ (defn- print-errors [errors ]
13+ (each error errors (print (string error " ." ))))
14+
1215# Keep commands sorted alphabetically.
1316(def argparse-params
1417 [" A command line utility for planning your days"
3740
3841(defn- run-with-file-path [arguments file-path ]
3942 (def load-file-result (file_repository/load file-path ))
40- (def error (load-file-result :error ))
41- (if error
42- (print error )
43+ (def errors (load-file-result :errors ))
44+ (if errors
45+ (print-errors errors )
4346 (let [plan-string (load-file-result :text )
4447 parse-result (plan_parser/parse plan-string )
4548 parse-error (parse-result :error )
Original file line number Diff line number Diff line change 1212(import ./commands/stats )
1313
1414(import ./date :as d )
15- (import ./file_repository )
1615(import ./schedule_parser )
1716
1817# backup command needs to be first
Original file line number Diff line number Diff line change 4949 (task/mark-as-missed task (day :date ))))
5050 tasks ))
5151
52- (defn- format-parse- errors [errors ]
52+ (defn- format-errors [errors ]
5353 (map (fn [error ] (string command " " (string/ascii-lower error ) " ." )) errors ))
5454
5555# # —————————————————————————————————————————————————————————————————————————————————————————————————
7272 (def argument (arguments " schedule-tasks" ))
7373 (if argument
7474 (let [load-file-result (file_repository/load argument )
75- error (load-file-result :error )]
76- (if error
77- {:errors [( string command " " ( string/ascii-lower error ))] }
75+ errors (load-file-result :errors )]
76+ (if errors
77+ {:errors ( format-errors errors ) }
7878 (let [parse-result (schedule_parser/parse (load-file-result :text ))
7979 errors (parse-result :errors )]
8080 (if errors
81- {:errors (format-parse- errors errors )}
81+ {:errors (format-errors errors )}
8282 {:command [schedule-tasks (parse-result :tasks ) (date/today )]}))))
8383 {}))
Original file line number Diff line number Diff line change 2828 ```
2929 [path ]
3030 (if (= (os/stat path ) nil )
31- {:error " File does not exist. " }
31+ {:errors [ " File does not exist" ] }
3232 {:text (string (file/read (file/open path ) :all ))}))
Original file line number Diff line number Diff line change 4343
4444(deftest load-from-file-that-does-not-exist
4545 (let [result (load " missing_file.md" )]
46- (is (= " File does not exist. " (result :error )))))
46+ (is (= " File does not exist" (first ( result :errors ) )))))
4747
4848(run-tests! )
You can’t perform that action at this time.
0 commit comments