3
3
package dev.schuberth.stan.cli
4
4
5
5
import com.github.ajalt.clikt.core.CliktCommand
6
- import com.github.ajalt.clikt.core.ProgramResult
7
6
import com.github.ajalt.clikt.core.UsageError
8
7
import com.github.ajalt.clikt.core.context
9
8
import com.github.ajalt.clikt.core.main
@@ -144,8 +143,7 @@ class Main : CliktCommand(), Logger {
144
143
println (" Successfully parsed ${parsedStatements.size} of ${statementFiles.size} statement(s) in $duration .\n " )
145
144
146
145
if (parsedStatements.isEmpty()) {
147
- System .err.println (" No statements found." )
148
- throw ProgramResult (2 )
146
+ throw UsageError (" No statements found." , " statementGlobs" )
149
147
}
150
148
151
149
println (" Checking parsed statements for consistency..." )
@@ -154,35 +152,31 @@ class Main : CliktCommand(), Logger {
154
152
155
153
sortedStatements.zipWithNext().forEach { (curr, next) ->
156
154
if (curr.bankId != next.bankId) {
157
- System .err. println (
155
+ logger.error {
158
156
" Statements '${curr.filename} ' (${curr.bankId} ) and '${next.filename} ' (${next.bankId} ) do not " +
159
157
" belong to the same bank."
160
- )
161
- throw ProgramResult (2 )
158
+ }
162
159
}
163
160
164
161
if (curr.accountId != next.accountId) {
165
- System .err. println (
162
+ logger.error {
166
163
" Statements '${curr.filename} ' (${curr.accountId} ) and '${next.filename} ' (${next.accountId} ) do " +
167
164
" not belong to the same account."
168
- )
169
- throw ProgramResult (2 )
165
+ }
170
166
}
171
167
172
168
if (curr.toDate.plusDays(1 ) != next.fromDate) {
173
- System .err. println (
169
+ logger.error {
174
170
" Statements '${curr.filename} ' (${curr.toDate} ) and '${next.filename} ' (${next.fromDate} ) are " +
175
171
" not consecutive."
176
- )
177
- throw ProgramResult (2 )
172
+ }
178
173
}
179
174
180
175
if (curr.balanceNew != next.balanceOld) {
181
- System .err. println (
176
+ logger.error {
182
177
" Balances of statements '${curr.filename} ' (${curr.balanceNew} ) and '${next.filename} ' " +
183
178
" (${next.balanceOld} ) are not successive."
184
- )
185
- throw ProgramResult (2 )
179
+ }
186
180
}
187
181
}
188
182
0 commit comments