loadConfig method
Loads and prepares configuration for endpoint generation.
Parses command-line arguments and constructs a EndpointConfig object with all necessary parameters for endpoint generation.
Implementation
EndpointConfig loadConfig(String morphemeYamlPath) {
final yamlData = YamlHelper.loadFileYaml(morphemeYamlPath);
final projectName =
yamlData['project_name'] ?? yamlData['name'] ?? 'morpheme';
final pathDir = join(
current,
'core',
'lib',
'src',
'data',
'remote',
);
final pathOutput = join(
pathDir,
'${projectName.toString().snakeCase}_endpoints.dart',
);
// Always look for json2dart files
final json2DartPaths = <String>[];
json2DartPaths.addAll(
find(
'*json2dart.yaml',
workingDirectory: join(current, 'json2dart'),
).toList(),
);
return EndpointConfig(
projectName: projectName,
outputPath: pathOutput,
json2DartPaths: json2DartPaths,
);
}