fix: don't print failure message when -h flag is passed (#2572)
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user