commands function
Implementation
Future<void> commands(List<String> arguments) async {
if (arguments.length == 0) {
_handleMenu();
exit(0);
}
List<String> argumentSplit = arguments[0].split(":");
if (argumentSplit.length == 0 || argumentSplit.length <= 1) {
writeInBlack('Invalid arguments ' + arguments.toString());
exit(2);
}
String type = argumentSplit[0];
String action = argumentSplit[1];
NyCommand? nyCommand;
switch (type) {
case "project":
{
nyCommand = _allProjectCommands
.firstWhereOrNull((command) => command.name == action);
break;
}
case "make":
{
nyCommand = _allMakeCommands
.firstWhereOrNull((command) => command.name == action);
break;
}
case "appicons":
{
nyCommand = _allAppIconsCommands
.firstWhereOrNull((command) => command.name == action);
break;
}
case "plugin":
{
nyCommand = _allAppIconsCommands
.firstWhereOrNull((command) => command.name == action);
break;
}
default:
{}
}
if (nyCommand == null) {
writeInBlack('Invalid arguments ' + arguments.toString());
return;
}
arguments.removeAt(0);
nyCommand.action!(arguments);
}