From 720efe4be2348427790ff6706eaf9f9175704d99 Mon Sep 17 00:00:00 2001 From: Rupesh Kalantre Date: Mon, 12 Oct 2020 19:14:29 +0530 Subject: [PATCH 1/3] added arguments parser --- src/ParseArguments.java | 96 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 src/ParseArguments.java diff --git a/src/ParseArguments.java b/src/ParseArguments.java new file mode 100644 index 0000000..6f9fc38 --- /dev/null +++ b/src/ParseArguments.java @@ -0,0 +1,96 @@ +// import java.io.File; + +public class ParseArguments { + // private String filename; + // private String delimiter; + + public ParseArguments(String[] args) { + try { + String arg = args[0]; // ArrayIndexOutOfBoundsException + if (arg.equals("--team")) { + System.out.println(); + teamInfo(); + System.out.println(); + System.exit(0); + } else if (arg.equals("--help")) { + System.out.println(); + manual(); + System.out.println(); + System.exit(0); + } + // else { + + // Checker check = new Checker(args); + // check.isChecked(); + + // String filePath = args[0]; + // File file = new File(filePath); + + // // check if file exists + // if(!file.exists()) { + // System.out.println("file doesn't exists at file path : " + filePath); + // System.exit(0); + // } + + // //default delimiter is '.' + // String Delimiter = "."; + // if(args.length > 1) { + // Delimiter = args[1]; + // } + + // //set the filename and Delimiter + // setFilename(filePath); + // setDelimiter(Delimiter); + // } + } catch (ArrayIndexOutOfBoundsException e) { + //In case user doesn't provide any arguments to jar file + System.out.println("\nPlease Enter arguments !\t(For more help, use '--help' tag)\n"); + System.exit(-1); + } + } + + // public void setFilename(String fileName) { + // this.filename = fileName; + // } + + // public void setDelimiter(String delimiter) { + // this.delimiter = delimiter; + // } + + // public String getFilename() { + // return this.filename; + // } + + // public String getDelimiter() { + // return this.delimiter; + // } + + private void teamInfo() { + System.out.println("<< Team Info >>\n"); + System.out.println("Team Name : Software Fighters"); + System.out.println("\nMembers : "); + System.out.println("\tManjeet Kapil (180010021) "); + System.out.println("\tHarsh Raj (180010017) "); + System.out.println("\tShriram Ghadge (180010015) "); + System.out.println("\tRupesh Kalantre (180010029) "); + } + + private void manual() { + System.out.println("--------- MANUAL ----------\n"); + String manual = "(This is a command-line program written in java to find no. of " + + "lines, words, average length in your Essay/writting.)\n" + + "\n\nHow-To guide : \n" + + "\n\tTo get the team Information : use '--team' flag with the jar file." + + "\n\t> $ java -jar --team\n" + + "\n\tTo get the manual : use '--help' flag with the jar file" + + "\n\t> $ java -jar --help\n" + + "\n\tTo use the jar file to find no. of average lines, words, total lines, execute following command:" + + "\n\t> $ java -jar \n" + + "\n\t**Note : here delimiter means the character with which your sentence ends. " + + "By default sentence ends with '.' character" + + "\n\tDefault value of minimum word length is 4, this is optional argument"; + + System.out.println(manual); + System.out.println("\n--------- END OF MANUAL ----------"); + } +} From 9f3f72cd18cd455ea4e57760dd4e9bf39eaa06d8 Mon Sep 17 00:00:00 2001 From: Rupesh Kalantre Date: Mon, 12 Oct 2020 22:10:32 +0530 Subject: [PATCH 2/3] modified build.sh --- build.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 06aea8a..77e2e1c 100644 --- a/build.sh +++ b/build.sh @@ -1,7 +1,9 @@ #add any supporting commands to create avglength.jar, the name of the java JAR file. +ant make-jar #add any supporting commands to print team info when passed the --team command-line argument -java -jar avglength.jar --team - +#java -jar avglength.jar --team +java -jar jars/avglength.jar --team #add any supporting commands to print the documentation on console when --help is passed as a command-line argument -java -jar avglength.jar --help +#java -jar avglength.jar --help +java -jar jars/avglength.jar --help From 8bd4a108d5da101601f5caf1b6b7f29bb70e158b Mon Sep 17 00:00:00 2001 From: Rupesh Kalantre Date: Mon, 12 Oct 2020 22:10:58 +0530 Subject: [PATCH 3/3] added build.xml for making jar --- build.xml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 build.xml diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..ee8060a --- /dev/null +++ b/build.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +