getHelp method
The getHelp method is used to get the help of the application.
The myControllers is a list of controllers that you want to show in the help. If it is null it will show all controllers.
you can call this method from the controller to get the help of the application.
Implementation
String getHelp([List<CappController>? myControllers]) {
var selectedControllers = myControllers ?? [...this.controllers, main];
var help = "Available commands:\n";
var index = 1;
for (var controller in selectedControllers) {
if (controller.name.isNotEmpty) {
help += "${index++}) ${controller.name}:\t${controller.description}\n";
} else {
help += "${controller.description}\n";
}
if (controller.options.isNotEmpty) {
help += "\n";
}
var indexOption = 0;
for (var option in controller.options) {
indexOption++;
help += " --${option.name}\t${option.description}\n";
if (option.shortName.isNotEmpty) {
help += " -${option.shortName}\n";
} else {
help += "\n";
}
if (indexOption < controller.options.length) {
help += "\n";
}
}
help += "${'─' * 30}\n";
}
return help;
}