discoverCustomCommands static method

Future<List<NyCommand>> discoverCustomCommands({
  1. Directory? projectDirectory,
  2. Iterable<String> reservedCommands = const [],
  3. void onWarning(
    1. String message
    )?,
})

Discovers the project's commands.json commands plus package commands (see discoverPackageCommands). Precedence: reservedCommands, project, packages.

Implementation

static Future<List<NyCommand>> discoverCustomCommands({
  Directory? projectDirectory,
  Iterable<String> reservedCommands = const [],
  void Function(String message)? onWarning,
}) async {
  final void Function(String message) warn =
      onWarning ?? MetroConsole.writeInYellow;

  final List<NyCommand> projectCommands = await _discoverProjectCommands(
    projectDirectory,
  );
  final List<NyCommand> packageCommands = await discoverPackageCommands(
    projectDirectory: projectDirectory,
    onWarning: warn,
  );

  return mergeCommands(
    projectCommands: projectCommands,
    packageCommands: packageCommands,
    reservedCommands: reservedCommands,
    onWarning: warn,
  );
}