rejectUnknownArgs function

int? rejectUnknownArgs(
  1. ArgResults results,
  2. FLILogger logger
)

Inspects a command's parsed results for stray positional arguments. Returns 64 (and logs a clear error) when any are present; returns null when the rest is empty so the caller can return code ?? null patternlessly.

Every subcommand calls this at the start of its run() so a typo like dart run flutter_launcher_icons_flavors generate foobar fails loudly instead of silently dropping the unrecognized token.

Implementation

int? rejectUnknownArgs(ArgResults results, FLILogger logger) {
  if (results.rest.isEmpty) {
    return null;
  }
  logger.error('Could not run command');
  logger.error(
    'Unknown argument(s): ${results.rest.join(', ')}. '
    'Use --help to see the supported flags.',
  );
  return 64;
}