printHelp method

  1. @override
void printHelp(
  1. CommandContext context
)
override

Prints the help information for this command.

Implementation

@override
void printHelp(CommandContext context) {
  context.console.info('Usage: ', newline: false);
  context.console.plain(context.input.executable, newline: false);
  context.console.warning(' <command>');

  if (description?.isNotEmpty == true) {
    context.console.newline();
    context.console.plain(description!);
  }

  final padding = switch (commands) {
    Map(isEmpty: true) => 2,
    Map(keys: final keys) => keys.map((it) => it.length).reduce(max) + 2,
  };

  if (commands.isNotEmpty) {
    context.console.newline();
    context.console.success('Commands:');
    for (final command in commands.entries) {
      context.console.outputHelpListChind(
        command.key,
        help: command.value.description,
        style: ConsoleStyle.warning,
        padding: padding,
      );
    }
  }
}