discoverCustomCommands static method

Future<List<NyCommand>> discoverCustomCommands()

Discovers custom commands from a JSON file.

Implementation

static Future<List<NyCommand>> discoverCustomCommands() async {
  try {
    final configFile = File('lib/app/commands/commands.json');
    if (await configFile.exists()) {
      final jsonStr = await configFile.readAsString();
      final List<dynamic> commandConfigs = jsonDecode(jsonStr);
      return discoverCommands(commandConfigs);
    }
  } catch (e) {
    MetroConsole.writeInRed(
      'Error loading custom commands: $e\n\nMake sure to create a commands.json file in the lib/app/commands directory.',
    );
  }
  return [];
}