// Path: src/main/java/com/thinksincode/tailstreamer/FileTailService.java
// @Service("fileTailService")
// public class FileTailService {
//     private Logger logger = LoggerFactory.getLogger(FileTailService.class);
//     
//     @Autowired
//     private FileWatcherService watcher;
//     
//     @Autowired
//     private FileContentReader reader;
//     
//     private Path file;
//     
//     /**
//      * Sets the file that will be tailed.
//      * @param filePath The path of the file to tail.
//      */
//     public void setFile(final String filePath) {
//         file = Paths.get(filePath).toAbsolutePath();
//     }
//     
//     /**
//      * Gets the path of the file being tailed.
//      * @return the absolute path of the file
//      */
//     public String getFilePath() {
//         return file.toString();
//     }
// 
//     /**
//      * Gets the name of the file being tailed.
//      * @return the file name only
//      */
//     public String getFileName() {
//         return file.getFileName().toString();
//     }
// 
//     /**
//      * Begins the file tail operation on a file.
//      */
//     @Async
//     public void tailFile() {
//         logger.info("Tailing " + file);
//         reader.openFile(file);
//         watcher.watchFile(file);
//     }
// }
// 
// Path: src/main/java/com/thinksincode/tailstreamer/TailStreamer.java
// @Configuration
// @EnableAsync
// @EnableAutoConfiguration
// @ComponentScan
// public class TailStreamer implements CommandLineRunner {
//     public static final String VERSION = "1.0";
// 
//     @Autowired
//     private FileTailService fileTailService;
//     
//     @Value("${nonOptionArgs}")
//     private String nonOptionArgs;
//     
//     @Override
//     public void run(String...args) {
//       String[] nonOptionArgsArr = nonOptionArgs.split(",");  
//       fileTailService.setFile(nonOptionArgsArr[0]);
//       fileTailService.tailFile();
//     }
// 
//     public static void main(String...args) {
//         System.setProperty("spring.config.name", "tailstreamer");
//         System.setProperty("spring.config.location", "../conf/");
// 
//         ArgumentProcessor argumentProcessor = new ArgumentProcessor();
//         if (argumentProcessor.parseArguments(args) && argumentProcessor.validateArguments()) {
//             OptionSet options = argumentProcessor.getOptions();
//             if (options.has("h")) {
//                 System.out.println(getHelpText());
//             } else if (options.has("v")) {
//                 System.out.println("TailStreamer version " + VERSION);
//             } else if (options.has("encryptPassword")) {
//                 BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
//                 System.out.println(encoder.encode((String) options.nonOptionArguments().get(0)));
//             } else {
//                 TailStreamerApplication app = new TailStreamerApplication(TailStreamer.class, argumentProcessor.getOptions());
//                 app.run(args);
//             }
//         } else {
//             System.err.println(argumentProcessor.getValidationErrorMessage());
//             System.out.println(getHelpText());
//             System.exit(1);
//         }
//     }   
//     
//     public static String getHelpText() {
//         return new StringBuilder()
//         .append("Usage: tailstreamer [options] file\n")
//         .append("  -h                           Print this message\n")
//         .append("  -v                           Display version information\n")
//         .append("  --encryptPassword <password> Encrypts a specified password\n")
//         .append("  --server.port=PORT           Listen on PORT (default 8080)\n")
//         .toString();
//     }
// }


import com.thinksincode.tailstreamer.FileTailService;
import com.thinksincode.tailstreamer.TailStreamer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
package com.thinksincode.tailstreamer.controller;


@Controller
public class MainController {

    /** The maximum filename length before truncation occurs. */
    private static final int MAX_FILENAME_LENGTH = 50;

    @Autowired
// Path: src/main/java/com/thinksincode/tailstreamer/FileTailService.java
// @Service("fileTailService")
// public class FileTailService {
//     private Logger logger = LoggerFactory.getLogger(FileTailService.class);
//     
//     @Autowired
//     private FileWatcherService watcher;
//     
//     @Autowired
//     private FileContentReader reader;
//     
//     private Path file;
//     
//     /**
//      * Sets the file that will be tailed.
//      * @param filePath The path of the file to tail.
//      */
//     public void setFile(final String filePath) {
//         file = Paths.get(filePath).toAbsolutePath();
//     }
//     
//     /**
//      * Gets the path of the file being tailed.
//      * @return the absolute path of the file
//      */
//     public String getFilePath() {
//         return file.toString();
//     }
// 
//     /**
//      * Gets the name of the file being tailed.
//      * @return the file name only
//      */
//     public String getFileName() {
//         return file.getFileName().toString();
//     }
// 
//     /**
//      * Begins the file tail operation on a file.
//      */
//     @Async
//     public void tailFile() {
//         logger.info("Tailing " + file);
//         reader.openFile(file);
//         watcher.watchFile(file);
//     }
// }
// 
// Path: src/main/java/com/thinksincode/tailstreamer/TailStreamer.java
// @Configuration
// @EnableAsync
// @EnableAutoConfiguration
// @ComponentScan
// public class TailStreamer implements CommandLineRunner {
//     public static final String VERSION = "1.0";
// 
//     @Autowired
//     private FileTailService fileTailService;
//     
//     @Value("${nonOptionArgs}")
//     private String nonOptionArgs;
//     
//     @Override
//     public void run(String...args) {
//       String[] nonOptionArgsArr = nonOptionArgs.split(",");  
//       fileTailService.setFile(nonOptionArgsArr[0]);
//       fileTailService.tailFile();
//     }
// 
//     public static void main(String...args) {
//         System.setProperty("spring.config.name", "tailstreamer");
//         System.setProperty("spring.config.location", "../conf/");
// 
//         ArgumentProcessor argumentProcessor = new ArgumentProcessor();
//         if (argumentProcessor.parseArguments(args) && argumentProcessor.validateArguments()) {
//             OptionSet options = argumentProcessor.getOptions();
//             if (options.has("h")) {
//                 System.out.println(getHelpText());
//             } else if (options.has("v")) {
//                 System.out.println("TailStreamer version " + VERSION);
//             } else if (options.has("encryptPassword")) {
//                 BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
//                 System.out.println(encoder.encode((String) options.nonOptionArguments().get(0)));
//             } else {
//                 TailStreamerApplication app = new TailStreamerApplication(TailStreamer.class, argumentProcessor.getOptions());
//                 app.run(args);
//             }
//         } else {
//             System.err.println(argumentProcessor.getValidationErrorMessage());
//             System.out.println(getHelpText());
//             System.exit(1);
//         }
//     }   
//     
//     public static String getHelpText() {
//         return new StringBuilder()
//         .append("Usage: tailstreamer [options] file\n")
//         .append("  -h                           Print this message\n")
//         .append("  -v                           Display version information\n")
//         .append("  --encryptPassword <password> Encrypts a specified password\n")
//         .append("  --server.port=PORT           Listen on PORT (default 8080)\n")
//         .toString();
//     }
// }


// Path: src/main/java/com/thinksincode/tailstreamer/controller/MainController.java
import com.thinksincode.tailstreamer.FileTailService;
import com.thinksincode.tailstreamer.TailStreamer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

package com.thinksincode.tailstreamer.controller;


@Controller
public class MainController {

    /** The maximum filename length before truncation occurs. */
    private static final int MAX_FILENAME_LENGTH = 50;

    @Autowired
    private FileTailService fileTailService;