À VÉRIFIER : Amélioration de la gestion des messages d'état dans CommandExecutor
This commit is contained in:
parent
29ad274f28
commit
307f6d38e6
@ -13,23 +13,23 @@ public class CommandExecutor {
|
||||
}
|
||||
|
||||
public void execute(Rule rule) {
|
||||
if (rule.getCommands().isEmpty()) {
|
||||
System.out.println("bake: Nothing to be done for '" + rule.getName() + "'.");
|
||||
return;
|
||||
}
|
||||
|
||||
// On vérifie d'abord si cette règle a besoin d'être mise à jour
|
||||
boolean ruleNeedsUpdate = rule.needsUpdate();
|
||||
if (ruleNeedsUpdate) {
|
||||
needsUpdate = true; // Au moins une règle doit être mise à jour
|
||||
}
|
||||
|
||||
// Si la règle a besoin d'être mise à jour et qu'il n'y a pas de commandes
|
||||
if (ruleNeedsUpdate && rule.getCommands().isEmpty()) {
|
||||
return; // On ne fait rien mais on ne montre pas de message
|
||||
}
|
||||
|
||||
for (String command : rule.getCommands()) {
|
||||
if (isCircular){
|
||||
System.out.println(command);
|
||||
}
|
||||
|
||||
// Mais on n'exécute que si nécessaire
|
||||
// On n'exécute que si nécessaire
|
||||
if (ruleNeedsUpdate) {
|
||||
try {
|
||||
if(!isCircular){
|
||||
@ -78,10 +78,19 @@ public class CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
// On affiche "up to date" seulement après avoir traité TOUTES les règles
|
||||
// et seulement si AUCUNE règle n'avait besoin d'être mise à jour
|
||||
if (rule.getName().equals(BakefileParser.getFirstTarget()) && !needsUpdate) {
|
||||
// On n'affiche le message "up to date" que si :
|
||||
// 1. C'est la première cible
|
||||
// 2. Aucune règle n'avait besoin d'être mise à jour
|
||||
// 3. On a des commandes à exécuter
|
||||
if (rule.getName().equals(BakefileParser.getFirstTarget()) && !needsUpdate && !rule.getCommands().isEmpty()) {
|
||||
System.out.println("bake: `" + rule.getName() + "' is up to date.");
|
||||
}
|
||||
// On affiche "Nothing to be done" uniquement si :
|
||||
// 1. C'est la première cible
|
||||
// 2. Aucune règle n'avait besoin d'être mise à jour
|
||||
// 3. On n'a PAS de commandes à exécuter
|
||||
else if (rule.getName().equals(BakefileParser.getFirstTarget()) && !needsUpdate && rule.getCommands().isEmpty()) {
|
||||
System.out.println("bake: Nothing to be done for '" + rule.getName() + "'.");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user