99import java .util .concurrent .Callable ;
1010
1111import org .jspecify .annotations .Nullable ;
12+ import org .slf4j .Logger ;
13+ import org .slf4j .LoggerFactory ;
1214
1315import java .util .Objects ;
1416import java .util .Optional ;
3133 mixinStandardHelpOptions = true ,
3234 usageHelpAutoWidth = true
3335)
34- public class PlantUMLToPng implements Callable <Integer > {
36+ public class MainApplication implements Callable <Integer > {
37+
38+ private static final Logger logger = LoggerFactory .getLogger (MainApplication .class );
3539
3640 @ Option (
3741 names = {"-f" , "--file" },
@@ -54,7 +58,7 @@ public class PlantUMLToPng implements Callable<Integer> {
5458 /**
5559 * Default constructor for CLI usage.
5660 */
57- public PlantUMLToPng () {
61+ public MainApplication () {
5862 this .fileValidator = new PlantUMLFileValidator ();
5963 this .fileService = new PlantUMLFileService ();
6064 this .watchService = new PlantUMLWatchService (fileService );
@@ -67,7 +71,7 @@ public PlantUMLToPng() {
6771 * @param fileService The PlantUML file service to use
6872 * @param watchService The watch service to use
6973 */
70- public PlantUMLToPng (PlantUMLFileValidator fileValidator , PlantUMLFileService fileService , PlantUMLWatchService watchService ) {
74+ public MainApplication (PlantUMLFileValidator fileValidator , PlantUMLFileService fileService , PlantUMLWatchService watchService ) {
7175 this .fileValidator = fileValidator ;
7276 this .fileService = fileService ;
7377 this .watchService = watchService ;
@@ -94,20 +98,20 @@ public CliResult execute() {
9498 return handleSingleFileConversion (inputFile );
9599 }
96100
97- System . out . println ("Use --help to see available options." );
101+ logger . info ("Use --help to see available options." );
98102 return CliResult .KO ;
99103 }
100104
101105 private CliResult handleSingleFileConversion (String inputFile ) {
102106 if (Objects .isNull (inputFile )) {
103- System . err . println ("Error: No input file specified. Use -f or --file option." );
107+ logger . error ("Error: No input file specified. Use -f or --file option." );
104108 return CliResult .KO ;
105109 }
106110
107111 // Validate input file using PlantUMLFileValidator
108112 Optional <Path > validatedPath = fileValidator .validatePlantUMLFile (inputFile );
109113 if (validatedPath .isEmpty ()) {
110- System . err . println ("Invalid PlantUML file: " + inputFile );
114+ logger . error ("Invalid PlantUML file: {}" , inputFile );
111115 return CliResult .KO ;
112116 }
113117
@@ -125,19 +129,19 @@ private CliResult handleWatchMode(String parameter) {
125129 if (Objects .isNull (parameter ) || parameter .trim ().isEmpty ()) {
126130 // Use current directory as default
127131 watchDirectory = Path .of (System .getProperty ("user.dir" ));
128- System . out . println ("Using current directory for watching: " + parameter );
132+ logger . info ("Using current directory for watching: {}" , parameter );
129133 } else {
130134 // Validate the provided directory
131135 watchDirectory = Path .of (parameter );
132136 if (!Files .exists (watchDirectory )) {
133- System . err . println ("Error: Directory does not exist: " + parameter );
137+ logger . error ("Error: Directory does not exist: {}" , parameter );
134138 return CliResult .KO ;
135139 }
136140 if (!Files .isDirectory (watchDirectory )) {
137- System . err . println ("Error: Path is not a directory: " + parameter );
141+ logger . error ("Error: Path is not a directory: {}" , parameter );
138142 return CliResult .KO ;
139143 }
140- System . out . println ("Using specified directory for watching: " + parameter );
144+ logger . info ("Using specified directory for watching: {}" , parameter );
141145 }
142146
143147 int watchResult = watchService .startWatching (watchDirectory );
@@ -147,10 +151,10 @@ private CliResult handleWatchMode(String parameter) {
147151 private static void printBanner () {
148152 try {
149153 System .out .println ();
150- String asciiArt = FigletFont .convertOneLine ("PlantUML to PNG CLI" );
154+ String asciiArt = FigletFont .convertOneLine ("Puml to Png CLI" );
151155 System .out .println (colorize (asciiArt , Attribute .GREEN_TEXT ()));
152156 } catch (IOException e ) {
153- System . out . println ("Error printing banner: " + e .getMessage ());
157+ logger . error ("Error printing banner: {}" , e .getMessage ());
154158 }
155159 }
156160
@@ -161,7 +165,7 @@ private static void printBanner() {
161165 */
162166 public static void main (String [] args ) {
163167 printBanner ();
164- PlantUMLToPng cli = new PlantUMLToPng ();
168+ MainApplication cli = new MainApplication ();
165169 int exitCode = new CommandLine (cli ).execute (args );
166170 System .exit (exitCode );
167171 }
0 commit comments