run method
Unified execution entrypoint, implemented by commands.
Implementation
@override
Future<int> run(
CliContext context,
) async {
final router = context.router;
final commands = router.getAllCommands();
const sep = '────────────────────────────────────────────────────────────';
final buffer = StringBuffer();
buffer.writeln(sep);
for (final line in _logo) {
buffer.writeln(line);
}
buffer.writeln(sep);
buffer.writeln('Usage');
buffer.writeln(' mono <command> [targets] [options]');
buffer.writeln(sep);
buffer.writeln('Notes');
buffer.writeln(
' - Built-in commands like get run on all packages when no targets are given.');
buffer.writeln(
' - External tasks require explicit targets; use "all" to run on all packages.');
buffer.writeln(sep);
buffer.writeln('Commands');
if (commands.isNotEmpty) {
final sorted = [...commands]..sort((a, b) => a.name.compareTo(b.name));
final maxNameLen = sorted
.map((c) => _displayName(c).length)
.fold<int>(0, (m, e) => e > m ? e : m);
for (final c in sorted) {
final name = _displayName(c);
final pad = ' ' * (maxNameLen - name.length);
buffer.writeln(' $name$pad ${c.description}');
}
}
buffer.writeln(sep);
buffer.writeln('Global options');
buffer.writeln(' --[no-]color --[no-]icons --[no-]timestamp');
buffer.writeln(sep);
stdout.writeln(buffer.toString().trimRight());
return 0;
}