Skip to content

Commit f2fbcfe

Browse files
committed
Extract print-errors-without-status-code to errors module
1 parent 62968a4 commit f2fbcfe

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/commands.janet

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
(import ./commands/stats)
1313

1414
(import ./date :as d)
15+
(import ./errors)
1516
(import ./schedule_parser)
1617

1718
# backup command needs to be first
@@ -27,10 +28,6 @@
2728
schedule_tasks/build-command
2829
stats/build-command])
2930

30-
(defn- print-errors [errors]
31-
(loop [error :in errors]
32-
(print error)))
33-
3431
## —————————————————————————————————————————————————————————————————————————————————————————————————
3532
## Public Interface
3633

@@ -51,7 +48,7 @@
5148
(def errors (filter identity (flatten (map (fn [c] (c :errors)) commands))))
5249
(if (any? errors)
5350
(do
54-
(print-errors errors)
51+
(errors/print-errors-without-status-code errors)
5552
plan)
5653
(reduce (fn [new-plan command-and-arguments]
5754
(def command (first (command-and-arguments :command)))

src/errors.janet

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
(defn format-command-errors [command errors]
1414
(map (fn [error] (string command " " (string/ascii-lower error) ".")) errors))
1515

16+
# TODO: This function should go away.
17+
(defn print-errors-without-status-code [errors]
18+
(loop [error :in errors]
19+
(print error)))
20+
1621
(defn print-errors [errors exit-status-code]
1722
(each error errors (print (string error ".")))
1823
(os/exit exit-status-code))

0 commit comments

Comments
 (0)