[ DartDev ] Fix issue where --help after a script name would be
interpreted by 'dart run'

Would prevent scripts from accepting their own '--help' option when
running with DartDev.

Fixes https://github.com/dart-lang/sdk/issues/43487

Change-Id: I5fca196529ae7670ee6a7c37701a5fffdad11aa1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164605
Reviewed-by: Janice Collins <jcollins@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
diff --git a/pkg/dartdev/lib/src/commands/run.dart b/pkg/dartdev/lib/src/commands/run.dart
index 8a0a2ef..ae2ec2a 100644
--- a/pkg/dartdev/lib/src/commands/run.dart
+++ b/pkg/dartdev/lib/src/commands/run.dart
@@ -179,7 +179,9 @@
       // The arg.contains('.') matches a file name pattern, i.e. some 'foo.dart'
       if (arg.contains('.')) {
         argsContainFile = true;
-      } else if (arg == '--help' || arg == '-h' || arg == 'help') {
+      } else if (!argsContainFile &&
+          (arg == '--help' || arg == '-h' || arg == 'help')) {
+        // Only print usage if a help flag is provided before the script name.
         printUsage();
         return 0;
       }