startGenerate method
void
startGenerate()
Generate based on config file
Implementation
void startGenerate() {
if (!ConfigLoader.exists()) {
print('Warning: api_model_generator.yaml not found. Falling back to interactive mode.');
startInteractive();
return;
}
print('🚀 Generating from configuration...');
final jsonPath = 'response.json'; // Default
if (!File(jsonPath).existsSync()) {
print('Error: $jsonPath not found.');
return;
}
dynamic json;
try {
_progress.start('Parsing $jsonPath...');
json = JsonParser.parseFile(jsonPath);
_progress.success('$jsonPath parsed');
} catch (e) {
_progress.error('Error parsing $jsonPath: $e');
return;
}
stdout.write('Enter model name: ');
final modelNameInput = stdin.readLineSync()?.trim();
if (modelNameInput == null || modelNameInput.isEmpty) {
print('Error: Model name is required!');
return;
}
final modelName = StringUtils.capitalize(modelNameInput);
String choice = '1';
if (config.generateService) choice = '2';
if (config.generateRepository) choice = '3';
_runGeneration(json, modelName, choice, true);
}