diff --git a/packages/shorebird_cli/lib/src/shorebird_cli_command_runner.dart b/packages/shorebird_cli/lib/src/shorebird_cli_command_runner.dart index 3234f8e5..ec872a81 100644 --- a/packages/shorebird_cli/lib/src/shorebird_cli_command_runner.dart +++ b/packages/shorebird_cli/lib/src/shorebird_cli_command_runner.dart @@ -216,7 +216,10 @@ Engine • revision ${shorebirdEnv.shorebirdEngineRevision}'''); } } - if (exitCode != ExitCode.success.code && logger.level != Level.verbose) { + // `runCommand` returns null in when the --help flag is passed. + if (exitCode != null && + exitCode != ExitCode.success.code && + logger.level != Level.verbose) { final fileAnIssue = link( uri: Uri.parse( 'https://github.com/shorebirdtech/shorebird/issues/new/choose', diff --git a/packages/shorebird_cli/test/src/shorebird_cli_command_runner_test.dart b/packages/shorebird_cli/test/src/shorebird_cli_command_runner_test.dart index 1d124d43..4c126bd9 100644 --- a/packages/shorebird_cli/test/src/shorebird_cli_command_runner_test.dart +++ b/packages/shorebird_cli/test/src/shorebird_cli_command_runner_test.dart @@ -112,6 +112,20 @@ void main() { verify(() => logger.info(commandRunner.usage)).called(1); }); + group('when runCommand returns null exitCode', () { + test('does not print failure text', () async { + final result = await runWithOverrides( + () => commandRunner.run(['--help']), + ); + expect(result, equals(ExitCode.success.code)); + verifyNever( + () => logger.info( + any(that: contains("If you aren't sure why this command failed")), + ), + ); + }); + }); + test('handles UsageException', () async { final result = await runWithOverrides( // fly_to_the_moon is not a valid command.