run method
Implementation
void run(List<String> arguments) async {
if (arguments.isEmpty) {
stdout.write('''\x1B[94m
_ __ ___ _ __ ____ ___
| | / / / | / | / / / _/ / |
| | / / / /| | / |/ / / / / /| |
| |/ / / ___ | / /| / _/ / / ___ |
|___/ /_/ |_|/_/ |_/ /___/ /_/ |_|
\x1B[0m\t\t\n\n''');
print(
'\x1B[32m -V, --version \x1B[0m\tDisplay this application version',
);
int longestCommandLength =
_commands.keys.reduce((a, b) => a.length > b.length ? a : b).length;
_commands.forEach((name, command) {
final paddedName = name.padRight(longestCommandLength);
print('\x1B[32m$paddedName\x1B[0m\t\t${command.description}');
});
return;
}
final commandName = arguments[0].toString().toLowerCase();
if (commandName == '-V' ||
commandName == '--version' ||
commandName == '--v') {
String version = await Service().fetchVaniaVersion();
print(' \x1B[1mVania Dart Framework \x1B[32m $version \x1B[0m');
return;
}
final command = _commands[commandName];
if (command == null) {
print(
' \x1B[41m\x1B[37m ERROR \x1B[0m Command "$commandName" is not defined.',
);
return;
}
if (!Directory('${Directory.current.path}/lib').existsSync() &&
!(commandName == 'create' || commandName == 'update')) {
print(
'\x1B[41m\x1B[37m ERROR \x1B[0m Please run this command from the root directory of the Vania project',
);
exit(0);
}
final commandArguments = arguments.sublist(1);
command.execute(commandArguments);
}