doRun method

  1. @override
Future<int> doRun()
override

Implementation

@override
Future<int> doRun() async {
  final name = argResults!['name'] as String;
  final config = CustomCommandsConfig.instance;

  if (!config.hasCommand(name)) {
    printError('Command not found: $name');
    return 1;
  }

  try {
    final removed = config.removeCommand(name);
    if (removed) {
      config.save();
      printInfo('Custom command removed: $name');
      printInfo('Config saved to: ${config.getOrCreateConfigPath()}');
      return 0;
    } else {
      printError('Failed to remove command: $name');
      return 1;
    }
  } catch (e) {
    printError('Failed to remove command: $e');
    return 1;
  }
}