selectedModules method
Resolves which optional modules the generated mono-repo should contain.
Explicit --network / --no-network style flags always win. Whatever is
left is asked for once, as a single multi-select, unless --defaults was
passed or there is no terminal to ask on.
Implementation
@visibleForTesting
Map<String, bool> selectedModules() {
final answered = <String, bool>{
for (final module in templateModules)
if (argResults.wasParsed(module.flag))
module.key: argResults[module.flag] as bool,
};
final shouldPrompt = answered.length < templateModules.length && _canPrompt;
final selection = shouldPrompt ? _promptForModules(answered) : answered;
final requested = <String, bool>{
for (final module in templateModules)
module.key: selection[module.key] ?? module.defaultValue,
};
final resolved = resolveModuleImplications(requested);
for (final module in templateModules) {
if (resolved[module.key]! && !requested[module.key]!) {
logger.info(
'${lightYellow.wrap('+')} ${module.label} is required by '
'${module.impliedBy.where((o) => resolved[o]!).join(', ')}, '
'adding it.',
);
}
}
return resolved;
}