printUsage method

void printUsage({
  1. String? error,
  2. AFCommand? command,
})

Implementation

void printUsage({
  String? error,
  AFCommand? command,
}) {
  final result = StringBuffer();

  if(command != null) {
    result.write(command.usage);
  } else {
    result.write('''
$description

Usage: $name <command> [arguments]

Available Commands
''');
    for(final command in commands) {
      result.write("  ${command.name} - ${command.description}\n");
    }
  }

  if(error != null) {
    result.write("\nERROR: $error\n");
  }
  print(result.toString());
}