formatGlobalUsage method
Formats global usage, grouping commands by namespace.
Implementation
String formatGlobalUsage({bool includeDescription = true}) {
final buffer = StringBuffer();
if (includeDescription && description.trim().isNotEmpty) {
buffer.writeln(description.trim());
buffer.writeln();
}
buffer.writeln(_heading('Usage:'));
buffer.writeln(' ${invocation.trim()}');
buffer.writeln();
buffer.writeln(_heading('Options:'));
final globalOptions = argParser.usage.trimRight();
if (globalOptions.isNotEmpty) {
buffer.writeln(indentBlock(_formatOptionsUsage(globalOptions), 2));
}
buffer.writeln();
buffer.writeln(_heading('Available commands:'));
buffer.writeln(
formatCommandListing(
_uniqueTopLevelEntries(),
namespaceSeparator: namespaceSeparator,
styleNamespace: _heading,
styleCommand: _command,
),
);
buffer.writeln();
buffer.writeln(
'Run ${_emphasize('"$executableName <command> --help"')} for more information about a command.',
);
return buffer.toString().trimRight();
}