From 80fe405bfb3f61d85679fe598e4b364b07b42ef2 Mon Sep 17 00:00:00 2001 From: Hampus Lavin Date: Mon, 18 Nov 2024 15:52:55 +0100 Subject: [PATCH] docs: add explanatory comment --- lib/src/better_command_runner/better_command_runner.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/src/better_command_runner/better_command_runner.dart b/lib/src/better_command_runner/better_command_runner.dart index 18ea764..b097de2 100644 --- a/lib/src/better_command_runner/better_command_runner.dart +++ b/lib/src/better_command_runner/better_command_runner.dart @@ -149,6 +149,11 @@ class BetterCommandRunner extends CommandRunner { return; } + // Checks if the command is valid (i.e. no unexpected arguments). + // If there are unexpected arguments this will trigger a [UsageException] + // which will be caught in the try catch around the super.runCommand call. + // Therefore, this ensures that the help event is not sent for + // commands that are invalid. var noUnexpectedArgs = topLevelResults.rest.isEmpty; if (noUnexpectedArgs) { _onAnalyticsEvent?.call(BetterCommandRunnerAnalyticsEvents.help);