Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't print failure message when -h flag is passed #2572

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading