Skip to content

Commit 9b10c86

Browse files
author
pseudonym
committed
refactor(#92): Better robustness
handles an extremely unlikely scenario in a better manner
1 parent 60d5090 commit 9b10c86

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/cli_tools/lib/src/better_command_runner/better_command_runner.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ class BetterCommandRunner<O extends OptionDefinition, T>
398398
}
399399

400400
static bool _isUsageOfHelpCommandRequested(final ArgResults topLevelResults) {
401-
// check whether Help Command is chosen
401+
// check whether `help` command is chosen
402402
final topLevelCommand = topLevelResults.command;
403403
if (topLevelCommand == null) {
404404
return false;
@@ -409,7 +409,11 @@ class BetterCommandRunner<O extends OptionDefinition, T>
409409
final helpCommand = topLevelCommand;
410410
// check whether it's allowed to get the usage-text for `help`
411411
if (!helpCommand.options.contains(_HelpCommandDummy.label)) {
412-
throw StateError('Upstream `package:args` has a breaking change');
412+
// rare scenario (if upstream `package:args` has a breaking change)
413+
// fortunately, corresponding test-cases shall fail as it
414+
// - tests the current behavior (e.g. args = ['help', '-h'])
415+
// - notifies the publisher(s) of this breaking change
416+
return false;
413417
}
414418
// case: `mock help -h`
415419
if (helpCommand.flag(_HelpCommandDummy.label)) {

0 commit comments

Comments
 (0)