Skip to content

Commit

Permalink
fix: don't print failure message when -h flag is passed (#2572)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanoltman authored Oct 23, 2024
1 parent 9d03a5c commit af8a8d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit af8a8d1

Please sign in to comment.