commandPath static method

String? commandPath(
  1. ArgResults topLevelResults
)

Returns the space-separated command name path of the command to run, including its subcommands (e.g. variable set).

Contains command names only - never option values or positional arguments, since those can hold project ids and other user data. Returns null if no command was resolved.

Implementation

static String? commandPath(final ArgResults topLevelResults) {
  final names = <String>[];
  ArgResults? commandResults = topLevelResults.command;
  while (commandResults != null) {
    final name = commandResults.name;
    if (name != null) {
      names.add(name);
    }
    commandResults = commandResults.command;
  }
  if (names.isEmpty) {
    return null;
  }
  return names.join(' ');
}