From 307f6d38e6ea0d4c5ee9bb96c22486cdafe9182a Mon Sep 17 00:00:00 2001 From: Moncef STITI <moncef.stiti@etu.u-pec.fr> Date: Thu, 6 Feb 2025 21:13:55 +0100 Subject: [PATCH] =?UTF-8?q?=C3=80=20V=C3=89RIFIER=20:=20Am=C3=A9lioration?= =?UTF-8?q?=20de=20la=20gestion=20des=20messages=20d'=C3=A9tat=20dans=20Co?= =?UTF-8?q?mmandExecutor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monlouyan/bakefile/CommandExecutor.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/fr/monlouyan/bakefile/CommandExecutor.java b/src/fr/monlouyan/bakefile/CommandExecutor.java index cf1509c..852693e 100644 --- a/src/fr/monlouyan/bakefile/CommandExecutor.java +++ b/src/fr/monlouyan/bakefile/CommandExecutor.java @@ -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() + "'."); + } } } \ No newline at end of file