loadConfig method
Loads and prepares configuration for feature generation.
Parses command-line arguments and constructs a FeatureConfig object with all necessary parameters for feature generation.
Implementation
FeatureConfig loadConfig(String featureName, String appsName) {
final snakeCaseFeatureName = featureName.snakeCase;
final snakeCaseAppsName = appsName.snakeCase;
String finalFeatureName = snakeCaseFeatureName;
if (snakeCaseAppsName.isNotEmpty &&
!RegExp('^${snakeCaseAppsName}_').hasMatch(snakeCaseFeatureName)) {
finalFeatureName = '${snakeCaseAppsName}_$snakeCaseFeatureName';
}
final pathApps = join(current, 'apps', snakeCaseAppsName);
String pathFeature = join(current, 'features', finalFeatureName);
if (snakeCaseAppsName.isNotEmpty) {
pathFeature = join(pathApps, 'features', finalFeatureName);
}
// Check if feature already exists
if (exists(pathFeature)) {
StatusHelper.failed('Feature already exists in $pathFeature.');
// This will exit the program, but we still return the config for consistency
}
return FeatureConfig(
featureName: finalFeatureName,
appsName: snakeCaseAppsName,
featurePath: pathFeature,
appsPath: pathApps,
isInApps: snakeCaseAppsName.isNotEmpty,
);
}