generateHelpMessage static method

String generateHelpMessage(
  1. List<Argument> arguments,
  2. String programName
)

Generates a command-line help message for the provided arguments.

arguments The list of arguments to generate help for. programName The name of the program. Returns a string containing the help message.

Implementation

static String generateHelpMessage(
    List<Argument<dynamic>> arguments, String programName) {
  final StringBuffer helpMessage = StringBuffer();
  helpMessage.writeln('Usage: $programName [options]');

  for (var arg in arguments) {
    final description = _getArgumentDescription(arg);
    final valueType = arg.getType().toString();
    helpMessage.writeln(
        '  --${arg.name} [${valueType.split('.').last}]  $description');
  }

  return helpMessage.toString();
}