commandEntry function
Implementation
void commandEntry(List<String> arguments) {
if (arguments.isEmpty) {
log('Usage: dart run splash_master <command>');
log('Command:');
log(' create To create and setup the splash screen');
return;
}
final argument = arguments[0];
final command = Command.fromString(argument);
switch (command) {
case Command.create:
if (arguments.length == 1) {
const filePath = 'pubspec.yaml';
try {
final yamlMap =
loadYaml(File(filePath).readAsStringSync()) as YamlMap;
if (yamlMap[YamlKeys.splashMasterKey].runtimeType != YamlMap) {
throw SplashMasterException(message: 'Unable to read yaml file.');
}
final splashData = yamlMap[YamlKeys.splashMasterKey];
if (splashData.runtimeType != YamlMap) {
log("splash_master section isn't formatted correctly.");
return;
}
/// [splashData] is data that is being extracted from the YAML file.
setupSplashScreen(splashData);
} catch (e) {
log(e.toString());
}
}
case Command.none:
log('Invalid command or arguments.');
}
}