@@ -176,10 +176,11 @@ impl Cli {
176
176
}
177
177
}
178
178
179
- fn no_log_and_no_checkins_warning ( & self ) -> Option < String > {
179
+ fn no_log_and_no_data_warning ( & self ) -> Option < String > {
180
180
let no_checkins: bool = self . cron . is_none ( ) && self . heartbeat . is_none ( ) ;
181
+ let no_errors: bool = self . error . is_none ( ) ;
181
182
182
- if no_checkins {
183
+ if no_checkins && no_errors {
183
184
let using: Option < & str > = if self . no_log {
184
185
Some ( "--no-log" )
185
186
} else if self . no_stdout && self . no_stderr {
@@ -190,7 +191,7 @@ impl Cli {
190
191
191
192
if let Some ( using) = using {
192
193
return Some ( format ! (
193
- "using {using} without either --cron or --heartbeat ; \
194
+ "using {using} without either --cron, --heartbeat or --error ; \
194
195
no data will be sent to AppSignal"
195
196
) ) ;
196
197
}
@@ -206,7 +207,7 @@ impl Cli {
206
207
warnings. push ( warning) ;
207
208
}
208
209
209
- if let Some ( warning) = self . no_log_and_no_checkins_warning ( ) {
210
+ if let Some ( warning) = self . no_log_and_no_data_warning ( ) {
210
211
warnings. push ( warning) ;
211
212
}
212
213
@@ -378,24 +379,46 @@ mod tests {
378
379
}
379
380
380
381
#[ test]
381
- fn cli_warnings_no_log_and_no_checkins ( ) {
382
- for ( args, warning) in [ (
382
+ fn cli_warnings_no_log_and_no_data ( ) {
383
+ for ( args, warning) in [
384
+ (
383
385
vec ! [ "--no-log" ] ,
384
- "using --no-log without either --cron or --heartbeat ; no data will be sent to AppSignal"
386
+ Some ( "using --no-log without either --cron, --heartbeat or --error ; no data will be sent to AppSignal" )
385
387
) ,
386
388
(
387
389
vec ! [ "--no-stdout" , "--no-stderr" ] ,
388
- "using --no-stdout and --no-stderr without either --cron or --heartbeat; no data will be sent to AppSignal"
389
- ) ] {
390
+ Some ( "using --no-stdout and --no-stderr without either --cron, --heartbeat or --error; no data will be sent to AppSignal" )
391
+ ) ,
392
+ (
393
+ vec ! [ "--no-log" , "--no-stdout" , "--no-stderr" ] ,
394
+ Some ( "using --no-log without either --cron, --heartbeat or --error; no data will be sent to AppSignal" )
395
+ ) ,
396
+ (
397
+ vec ! [ "--no-log" , "--cron" , "some-cron" ] ,
398
+ None
399
+ ) ,
400
+ (
401
+ vec ! [ "--no-log" , "--heartbeat" , "some-hearttbeat" ] ,
402
+ None
403
+ ) ,
404
+ (
405
+ vec ! [ "--no-log" , "--error" , "some-error" ] ,
406
+ None
407
+ )
408
+ ] {
390
409
let cli = Cli :: try_parse_from (
391
410
with_required_args ( args)
392
411
393
412
) . expect ( "failed to parse CLI arguments" ) ;
394
413
395
414
let warnings = cli. warnings ( ) ;
396
415
397
- assert_eq ! ( warnings. len( ) , 1 ) ;
398
- assert_eq ! ( warnings[ 0 ] , warning) ;
416
+ if let Some ( warning) = warning {
417
+ assert_eq ! ( warnings. len( ) , 1 ) ;
418
+ assert_eq ! ( warnings[ 0 ] , warning) ;
419
+ } else {
420
+ assert ! ( warnings. is_empty( ) ) ;
421
+ }
399
422
}
400
423
}
401
424
0 commit comments