From 01c5954b5b94b1e8ac6156f0a6c6f2ec05ca7c13 Mon Sep 17 00:00:00 2001 From: Moncef STITI <moncef.stiti@etu.u-pec.fr> Date: Wed, 12 Mar 2025 16:34:15 +0100 Subject: [PATCH] Ajout de la gestion des commandes silencieuses dans CommandExecutor --- src/fr/monlouyan/bakefile/CommandExecutor.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/fr/monlouyan/bakefile/CommandExecutor.java b/src/fr/monlouyan/bakefile/CommandExecutor.java index 5aeaa02..a4d6261 100644 --- a/src/fr/monlouyan/bakefile/CommandExecutor.java +++ b/src/fr/monlouyan/bakefile/CommandExecutor.java @@ -71,18 +71,25 @@ public class CommandExecutor { } for (String command : rule.getCommands()) { + // Vérifier si la commande commence par @ (ne pas afficher la commande) + boolean silent = command.startsWith("@"); + // Enlever le @ si présent pour exécuter la commande correctement + String actualCommand = silent ? command.substring(1) : command; + if (isCircular){ - System.out.println(command); + if (!silent) { + System.out.println(actualCommand); + } } // On n'exécute que si nécessaire if (ruleNeedsUpdate) { try { - if(!isCircular){ - System.out.println(command); + if(!isCircular && !silent){ + System.out.println(actualCommand); } - if (debug) System.out.println("Debug: Executing " + command); - ProcessBuilder pb = new ProcessBuilder("sh", "-c", command); + if (debug) System.out.println("Debug: Executing " + actualCommand); + ProcessBuilder pb = new ProcessBuilder("sh", "-c", actualCommand); pb.inheritIO(); Process process = pb.start();