<commit_before>/**
Khalid
*/
package org.sikuli.slides.guis;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;

import org.sikuli.slides.utils.Constants;
import org.sikuli.slides.utils.MyFileFilter;

/**
 * sikuli-slides Command Line tool using POSIX like options.
 * 
 * @author Khalid
 *
 */
public class MainCommandLine {
	private static final String applicationName = "sikuli-slides";
	
	/**
	* Parse the command-line arguments as POSIX like options (one character long option).
	* @param args Command-line arguments
	* @return the .pptx file name
	*/
	private static String usePosixParser(final String[] args)  
	{
		final CommandLineParser parser = new PosixParser();  
	    final Options posixOptions = getPOSIXCommandLineOptions();  
	    CommandLine cmd;  
	    try{
	    	cmd = parser.parse(posixOptions, args);  
	        if (cmd.hasOption("w")){
	        	try{
	        		int wait=Integer.parseInt(cmd.getOptionValue("w"));
	        		Constants.MaxWaitTime=wait;
	        	}
	        	catch(Exception exception){
	    			printUsage(applicationName, getPOSIXCommandLineOptions(), System.out);
	    			displayBlankLine();
	        	} 
	        }
	        final String[] remainingArguments = cmd.getArgs();
	        if(remainingArguments==null){
	        	printUsage(applicationName, getPOSIXCommandLineOptions(), System.out);
	        	return null;
	        }
	        else if(remainingArguments.length>0){
	        	MyFileFilter myFileFilter=new MyFileFilter();
	        	String FileName=remainingArguments[0];
	        	File source_file=new File(FileName);
	        	if(myFileFilter.accept(source_file)){
	        		return source_file.getAbsolutePath();
	        	}
	        	else{
	        		printUsage(applicationName, getPOSIXCommandLineOptions(), System.out);
	        	}
	        }
	    }
	    catch (ParseException e){  
	    	e.printStackTrace();  
	    }
		return null;
	}
	
	/**
	 * Return all valid POSIX command-line options
	 * @return valid POSIX command-line options
	 */
	private static Options getPOSIXCommandLineOptions() {
		final Options posixOptions=new Options();
		posixOptions.addOption("w",true,
				"the maximum time to wait in milliseconds to find a target on the screen.");
		return posixOptions;
	}
	
	private static void showTextHeader(final OutputStream out){
		String textHeader="sikuli-slides -- GUI automation using presentation slides";
		try{
			out.write(textHeader.getBytes());
		}
		catch (IOException ioEx){
			System.out.println(textHeader);
		}
	}
	
	/**
	 * print usage information to provided OutputStream
	 * @param applicationName Name of application to list in usage
	 * @param options Command-line options to be part of usage
	 * @param out OutputStream to which to write the usage information
	 */
	public static void printUsage(final String applicationName, final Options options,final OutputStream out)
	{
		final PrintWriter writer = new PrintWriter(out);  
	    final HelpFormatter usageFormatter = new HelpFormatter();  <commit_msg>change command line tool text header<commit_after>/**
Khalid
*/
package org.sikuli.slides.guis;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;

import org.sikuli.slides.utils.Constants;
import org.sikuli.slides.utils.MyFileFilter;

/**
 * sikuli-slides Command Line tool using POSIX like options.
 * 
 * @author Khalid
 *
 */
public class MainCommandLine {
	private static final String applicationName = "sikuli-slides";
	
	/**
	* Parse the command-line arguments as POSIX like options (one character long option).
	* @param args Command-line arguments
	* @return the .pptx file name
	*/
	private static String usePosixParser(final String[] args)  
	{
		final CommandLineParser parser = new PosixParser();  
	    final Options posixOptions = getPOSIXCommandLineOptions();  
	    CommandLine cmd;  
	    try{
	    	cmd = parser.parse(posixOptions, args);  
	        if (cmd.hasOption("w")){
	        	try{
	        		int wait=Integer.parseInt(cmd.getOptionValue("w"));
	        		Constants.MaxWaitTime=wait;
	        	}
	        	catch(Exception exception){
	    			printUsage(applicationName, getPOSIXCommandLineOptions(), System.out);
	    			displayBlankLine();
	        	} 
	        }
	        final String[] remainingArguments = cmd.getArgs();
	        if(remainingArguments==null){
	        	printUsage(applicationName, getPOSIXCommandLineOptions(), System.out);
	        	return null;
	        }
	        else if(remainingArguments.length>0){
	        	MyFileFilter myFileFilter=new MyFileFilter();
	        	String FileName=remainingArguments[0];
	        	File source_file=new File(FileName);
	        	if(myFileFilter.accept(source_file)){
	        		return source_file.getAbsolutePath();
	        	}
	        	else{
	        		printUsage(applicationName, getPOSIXCommandLineOptions(), System.out);
	        	}
	        }
	    }
	    catch (ParseException e){  
	    	e.printStackTrace();  
	    }
		return null;
	}
	
	/**
	 * Return all valid POSIX command-line options
	 * @return valid POSIX command-line options
	 */
	private static Options getPOSIXCommandLineOptions() {
		final Options posixOptions=new Options();
		posixOptions.addOption("w",true,
				"the maximum time to wait in milliseconds to find a target on the screen.");
		return posixOptions;
	}
	
	private static void showTextHeader(final OutputStream out){
		String textHeader="sikuli-slides -- accessible visual automation";
		try{
			out.write(textHeader.getBytes());
		}
		catch (IOException ioEx){
			System.out.println(textHeader);
		}
	}
	
	/**
	 * print usage information to provided OutputStream
	 * @param applicationName Name of application to list in usage
	 * @param options Command-line options to be part of usage
	 * @param out OutputStream to which to write the usage information
	 */
	public static void printUsage(final String applicationName, final Options options,final OutputStream out)
	{
		final PrintWriter writer = new PrintWriter(out);  
	    final HelpFormatter usageFormatter = new HelpFormatter();  
{'fraction_non_alphanumeric': 0.09477959981946743, 'fraction_numerical': 0.0006017752369489995, 'mean_word_length': 3.2724935732647813, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2557664', 'n_tokens_mistral': 2033, 'n_tokens_neox': 1861, 'n_words': 491}