Update command parser 2.0
This commit is contained in:
parent
edff961ad3
commit
491f5c7753
@ -1,4 +1,10 @@
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import commands.Analyse;
|
||||
import commands.Build;
|
||||
import commands.Evaluate;
|
||||
import commands.Generate;
|
||||
import commands.Produce;
|
||||
import commands.Read;
|
||||
import picocli.CommandLine;
|
||||
import picocli.CommandLine.*;
|
||||
@ -17,17 +23,32 @@ import picocli.CommandLine.*;
|
||||
" \\/ \\/ \\/ \\/ \n" +
|
||||
" \n" ,
|
||||
footer = "\n\n ---- Provided by IUT Info Nice S3T-G4 ---- \n",
|
||||
description = "description"
|
||||
description = ""
|
||||
)
|
||||
|
||||
|
||||
public class Exec implements Callable <Void> {
|
||||
|
||||
@Spec
|
||||
Model.CommandSpec spec; // Permet de tager la commande pour l'appeler dans la surcharge de call()
|
||||
|
||||
// Système d'options et paramètres de commande de l'API
|
||||
|
||||
@Option(names= {"-v","--version"}, versionHelp = true, arity = "0", order = 1, description = "Displays version info")
|
||||
boolean version; // Paramètre associé (versionHelp génere l'aide de version automatiquement)
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
|
||||
// Système de subcommand semblable à celui de git permettant d'appeler les classes relatives
|
||||
|
||||
CommandLine cmd = new CommandLine (new Exec())
|
||||
.addSubcommand("-r", new Read(System.out))
|
||||
.addSubcommand("help", new HelpCommand());
|
||||
.addSubcommand("-r", new Read(System.out)) // nom commande, objet commande
|
||||
.addSubcommand("-b", new Build(System.out))
|
||||
.addSubcommand("-g", new Generate(System.out))
|
||||
.addSubcommand("-p", new Produce(System.out))
|
||||
.addSubcommand("-a", new Analyse(System.out))
|
||||
.addSubcommand("-e", new Evaluate(System.out))
|
||||
.addSubcommand("help", new HelpCommand()); // Aide générée automatiquement par l'API
|
||||
|
||||
cmd.execute(args);
|
||||
|
||||
@ -36,6 +57,8 @@ public class Exec implements Callable <Void> {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
|
||||
CommandLine.usage(this.spec, System.out); // Retourne l'aide générée par l'API s'il n'y a pas d'arguments
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,26 +1,31 @@
|
||||
package commands;
|
||||
import java.io.PrintStream;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import picocli.CommandLine;
|
||||
//import picocli.CommandLine;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
|
||||
@Command(
|
||||
name = "analyse",
|
||||
name = "-a",
|
||||
version = "Version 1.0",
|
||||
sortOptions = false,
|
||||
usageHelpWidth = 60,
|
||||
header = " -- Nicely Generated and Corrected Copies -- \n",
|
||||
footer = "\n Provided by IUT Info Nice S3T-G4",
|
||||
description = "description"
|
||||
header = "Analyse command - Questions' answers identification",
|
||||
footer = "",
|
||||
description = "\nAnalyzes scanned copies (pdf files) provided to identify student and questions' answers\n"
|
||||
)
|
||||
|
||||
|
||||
public class Analyse implements Callable <Void> {
|
||||
|
||||
@Option(names= {"-a","--analyse"}, arity = "0", order = 1, description = "analyse mode")
|
||||
boolean analyse;
|
||||
@Spec
|
||||
Model.CommandSpec spec;
|
||||
|
||||
@Option(names= {"-help"}, arity = "0", order = 1, description = "command help")
|
||||
boolean help;
|
||||
|
||||
@Option(names= {"-u"}, arity = "1", order = 2, description = "update mode")
|
||||
int step;
|
||||
|
||||
@ -28,24 +33,33 @@ public class Analyse implements Callable <Void> {
|
||||
int vb_level;
|
||||
|
||||
@Option(names= {"-d"}, arity = "1", order = 4, defaultValue = "copies", description ="directory")
|
||||
String directory;
|
||||
String directory_name;
|
||||
|
||||
@Parameters(arity = "0..1", defaultValue = "./source.txt", description ="source path")
|
||||
String source_path;
|
||||
|
||||
|
||||
|
||||
public Analyse(PrintStream out) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
if(analyse) {
|
||||
System.out.println("Analyse mode activated ...");
|
||||
System.out.println("Update : "+step);
|
||||
System.out.println("Verbose : "+vb_level);
|
||||
System.out.println("Directory : "+directory);
|
||||
System.out.println("Source : "+source_path);
|
||||
}
|
||||
|
||||
if(help){
|
||||
CommandLine.usage(this.spec, System.out);
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
System.out.println("\nAnalyse mode activated ...\n");
|
||||
System.out.println("Update : "+step +"\n"+
|
||||
"Verbose : "+vb_level +"\n"+
|
||||
"Directory : "+directory_name +"\n"+
|
||||
"Source : "+source_path +"\n");
|
||||
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
@ -1,25 +1,30 @@
|
||||
package commands;
|
||||
import java.io.PrintStream;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import picocli.CommandLine;
|
||||
//import picocli.CommandLine;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
|
||||
@Command(
|
||||
name = "ngcc",
|
||||
name = "-b",
|
||||
version = "Version 1.0",
|
||||
sortOptions = false,
|
||||
usageHelpWidth = 60,
|
||||
header = " -- Nicely Generated and Corrected Copies -- \n",
|
||||
footer = "\n Provided by IUT Info Nice S3T-G4",
|
||||
description = "description"
|
||||
header = "Build command - Create standard test copy",
|
||||
footer = "",
|
||||
description = "\nCreate a standard test copy accepted by the application.\n"
|
||||
)
|
||||
|
||||
|
||||
public class Build implements Callable <Void> {
|
||||
|
||||
@Option(names= {"-b","--build"}, arity = "0", order = 1, description = "build mode")
|
||||
boolean build;
|
||||
@Spec
|
||||
Model.CommandSpec spec;
|
||||
|
||||
@Option(names= {"-help"}, arity = "0", order = 1, description = "command help")
|
||||
boolean help;
|
||||
|
||||
@Option(names= {"-u"}, arity = "1", order = 2, description = "update mode")
|
||||
int step;
|
||||
@ -34,17 +39,25 @@ public class Build implements Callable <Void> {
|
||||
String source_path;
|
||||
|
||||
|
||||
public Build(PrintStream out) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
if(build) {
|
||||
System.out.println("Build mode activated ...");
|
||||
System.out.println("Update : "+step);
|
||||
System.out.println("Verbose : "+vb_level);
|
||||
System.out.println("Answer : "+answer_name);
|
||||
System.out.println("Source : "+source_path);
|
||||
}
|
||||
|
||||
if(help){
|
||||
CommandLine.usage(this.spec, System.out);
|
||||
}
|
||||
else {
|
||||
|
||||
System.out.println("\nBuild mode activated ...\n");
|
||||
System.out.println("Update : "+step +"\n"+
|
||||
"Verbose : "+vb_level +"\n"+
|
||||
"Directory : "+answer_name +"\n"+
|
||||
"Source : "+source_path +"\n");
|
||||
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
@ -1,25 +1,31 @@
|
||||
package commands;
|
||||
import java.io.PrintStream;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import picocli.CommandLine;
|
||||
//import picocli.CommandLine;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
|
||||
@Command(
|
||||
name = "evaluate",
|
||||
name = "-e",
|
||||
version = "Version 1.0",
|
||||
sortOptions = false,
|
||||
usageHelpWidth = 60,
|
||||
header = " -- Nicely Generated and Corrected Copies -- \n",
|
||||
footer = "\n Provided by IUT Info Nice S3T-G4",
|
||||
description = "description"
|
||||
header = "Evaluate command - Mark evaluation ",
|
||||
footer = "",
|
||||
description = "\nEvaluate each copies' mark based on the analysis performed previously."
|
||||
+ " Can be executed several times to take changes into account.\n"
|
||||
)
|
||||
|
||||
|
||||
public class Evaluate implements Callable <Void> {
|
||||
|
||||
@Option(names= {"-e","--evaluate"}, arity = "0", order = 1, description = "evaluate mode")
|
||||
boolean evaluate;
|
||||
@Spec
|
||||
Model.CommandSpec spec;
|
||||
|
||||
@Option(names= {"-help"}, arity = "0", order = 1, description = "command help")
|
||||
boolean help;
|
||||
|
||||
@Option(names= {"-u"}, arity = "1", order = 2, description = "update mode")
|
||||
int step;
|
||||
@ -34,27 +40,29 @@ public class Evaluate implements Callable <Void> {
|
||||
String source_path;
|
||||
|
||||
|
||||
public boolean isCsv(String file) {
|
||||
return file.endsWith(".csv");
|
||||
|
||||
// public boolean isCsv(String file) {
|
||||
// return file.endsWith(".csv");
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
public Evaluate(PrintStream out) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
if(evaluate) {
|
||||
System.out.println("Generate mode activated ...");
|
||||
System.out.println("Update : "+step);
|
||||
System.out.println("Verbose : "+vb_level);
|
||||
|
||||
if (isCsv(result_name)) {
|
||||
System.out.println("Result : "+result_name);
|
||||
}
|
||||
else {
|
||||
System.out.println("The specified name for the result file is invalid");
|
||||
//System.out.println("Result : "+result_name+".csv");
|
||||
}
|
||||
|
||||
System.out.println("Source : "+source_path);
|
||||
|
||||
if(help){
|
||||
CommandLine.usage(this.spec, System.out);
|
||||
}
|
||||
else {
|
||||
|
||||
System.out.println("\nEvaluate mode activated ...\n");
|
||||
System.out.println("Update : "+step +"\n"+
|
||||
"Verbose : "+vb_level +"\n"+
|
||||
"Result : "+result_name +"\n"+
|
||||
"Source : "+source_path +"\n");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -1,25 +1,30 @@
|
||||
package commands;
|
||||
import java.io.PrintStream;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import picocli.CommandLine;
|
||||
//import picocli.CommandLine;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
|
||||
@Command(
|
||||
name = "generate",
|
||||
name = "-g",
|
||||
version = "Version 1.0",
|
||||
sortOptions = false,
|
||||
usageHelpWidth = 60,
|
||||
header = " -- Nicely Generated and Corrected Copies -- \n",
|
||||
footer = "\n Provided by IUT Info Nice S3T-G4",
|
||||
description = "description"
|
||||
header = "Generate command - Subject and answer generation",
|
||||
footer = "",
|
||||
description = "\nSubject generation and associated answer with the source document.\n"
|
||||
)
|
||||
|
||||
|
||||
public class Generate implements Callable <Void> {
|
||||
|
||||
@Option(names= {"-g","--generate"}, arity = "0", order = 1, description = "generate mode")
|
||||
boolean generate;
|
||||
@Spec
|
||||
Model.CommandSpec spec;
|
||||
|
||||
@Option(names= {"-help"}, arity = "0", order = 1, description = "command help")
|
||||
boolean help;
|
||||
|
||||
@Option(names= {"-u"}, arity = "1", order = 2, description = "update mode")
|
||||
int step;
|
||||
@ -37,30 +42,31 @@ public class Generate implements Callable <Void> {
|
||||
String source_path;
|
||||
|
||||
|
||||
public boolean isPdf(String file) {
|
||||
return file.endsWith(".pdf");
|
||||
|
||||
// public boolean isPdf(String file) {
|
||||
// return file.endsWith(".pdf");
|
||||
//
|
||||
// }
|
||||
|
||||
public Generate(PrintStream out) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
if(generate) {
|
||||
System.out.println("Generate mode activated ...");
|
||||
System.out.println("Update : "+step);
|
||||
System.out.println("Verbose : "+vb_level);
|
||||
System.out.println("Topic : "+topic_name); //isPdf ...
|
||||
|
||||
if (isPdf(answer_name)) {
|
||||
System.out.println("Answer : "+answer_name);
|
||||
}
|
||||
else {
|
||||
System.out.println("The specified name for the result file is invalid");
|
||||
//System.out.println("Answer : "+answer_name+".pdf");
|
||||
}
|
||||
|
||||
System.out.println("Source : "+source_path);
|
||||
}
|
||||
|
||||
if(help){
|
||||
CommandLine.usage(this.spec, System.out);
|
||||
}
|
||||
else {
|
||||
|
||||
System.out.println("\nGenerate mode activated ...\n");
|
||||
System.out.println("Update : "+step +"\n"+
|
||||
"Verbose : "+vb_level +"\n"+
|
||||
"Topic : "+topic_name +"\n"+
|
||||
"Answer : "+answer_name +"\n"+
|
||||
"Source : "+source_path +"\n");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
@ -1,49 +0,0 @@
|
||||
package commands;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
//import picocli.CommandLine;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
|
||||
@Command(
|
||||
name = "Help command",
|
||||
version = "Version 1.0",
|
||||
sortOptions = false,
|
||||
usageHelpWidth = 60,
|
||||
header = " ---- Nicely Generated and Corrected Copies ---- \n" +
|
||||
" _______ _________________ ________ \n" +
|
||||
" \\ \\ / _____/\\_ ___ \\\\_ ___ \\ \n" +
|
||||
" / | \\/ \\ ___/ \\ \\// \\ \\/ \n" +
|
||||
" / | \\ \\_ \\ \\ \\___\\ \\___ \n" +
|
||||
" \\____|__ /\\______ /\\______ /\\______ / \n" +
|
||||
" \\/ \\/ \\/ \\/ \n" +
|
||||
" \n" ,
|
||||
footer = "\n ---- Provided by IUT Info Nice S3T-G4 ---- ",
|
||||
description = "description"
|
||||
)
|
||||
|
||||
|
||||
public class Help implements Callable <Void> {
|
||||
|
||||
@Option(names= {"help", "--help"}, required = true, arity = "0", order = 1, description = "help")
|
||||
boolean help;
|
||||
|
||||
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
if(help) {
|
||||
System.out.println(
|
||||
"\nCommands List : \n\n" +
|
||||
"-b, --build build mode \n" +
|
||||
"-r, --read read mode \n" +
|
||||
"-g, --generate generate mode \n" +
|
||||
"-p, --produce produce mode \n" +
|
||||
"-a, --analyse analyse mode \n" +
|
||||
"-e, --evaluate evaluate mode \n" );
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
@ -1,25 +1,30 @@
|
||||
package commands;
|
||||
import java.io.PrintStream;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import picocli.CommandLine;
|
||||
//import picocli.CommandLine;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
|
||||
@Command(
|
||||
name = "produce",
|
||||
name = "-p",
|
||||
version = "Version 1.0",
|
||||
sortOptions = false,
|
||||
usageHelpWidth = 60,
|
||||
header = " -- Nicely Generated and Corrected Copies -- \n",
|
||||
footer = "\n Provided by IUT Info Nice S3T-G4",
|
||||
header = "Produce command - Correction subject generation",
|
||||
footer = "\nProduce correction subject associated to the source file.\n",
|
||||
description = "description"
|
||||
)
|
||||
|
||||
|
||||
public class Produce implements Callable <Void> {
|
||||
|
||||
@Option(names= {"-p","--produce"}, arity = "0", order = 1, description = "produce mode")
|
||||
boolean produce;
|
||||
@Spec
|
||||
Model.CommandSpec spec;
|
||||
|
||||
@Option(names= {"-help"}, arity = "0", order = 1, description = "command help")
|
||||
boolean help;
|
||||
|
||||
@Option(names= {"-u"}, arity = "1", order = 2, description = "update mode")
|
||||
int step;
|
||||
@ -34,27 +39,29 @@ public class Produce implements Callable <Void> {
|
||||
String source_path;
|
||||
|
||||
|
||||
public boolean isPdf(String file) {
|
||||
return file.endsWith(".pdf");
|
||||
|
||||
// public boolean isPdf(String file) {
|
||||
// return file.endsWith(".pdf");
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
public Produce(PrintStream out) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
if(produce) {
|
||||
System.out.println("Produce mode activated ...");
|
||||
System.out.println("Update : "+step);
|
||||
System.out.println("Verbose : "+vb_level);
|
||||
|
||||
if (isPdf(sheet_name)) {
|
||||
System.out.println("Sheet : "+sheet_name);
|
||||
}
|
||||
else {
|
||||
System.out.println("The specified name for the result file is invalid");
|
||||
//System.out.println("Sheet : "+sheet_name+".pdf");
|
||||
}
|
||||
|
||||
System.out.println("Source : "+source_path);
|
||||
|
||||
if(help){
|
||||
CommandLine.usage(this.spec, System.out);
|
||||
}
|
||||
else {
|
||||
|
||||
System.out.println("\nProduce mode activated ...\n");
|
||||
System.out.println("Update : "+step +"\n"+
|
||||
"Verbose : "+vb_level +"\n"+
|
||||
"Sheet : "+sheet_name +"\n"+
|
||||
"Source : "+source_path +"\n");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -16,14 +16,22 @@ import java.util.concurrent.Callable;
|
||||
version = "Version 1.0",
|
||||
sortOptions = false,
|
||||
usageHelpWidth = 60,
|
||||
header = "Read command",
|
||||
footer = "\n Provided by IUT Info Nice S3T-G4",
|
||||
description = "description"
|
||||
header = "Read command - Automatic entry",
|
||||
footer = "",
|
||||
description = "\nAnalyzes all scanned copies (pdf files) provided to recognize student's name and mark.\n"
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
public class Read implements Callable <Void> {
|
||||
|
||||
@Spec
|
||||
Model.CommandSpec spec;
|
||||
|
||||
@Option(names= {"-help"}, arity = "0", order = 1, description = "command help")
|
||||
boolean help;
|
||||
|
||||
@Option(names= {"-u"}, arity = "1", order = 2, description = "update mode")
|
||||
int step;
|
||||
|
||||
@ -40,42 +48,66 @@ public class Read implements Callable <Void> {
|
||||
String source_path;
|
||||
|
||||
|
||||
// Flux de sortie si nécéssaire
|
||||
public Read(PrintStream out) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isCsv(String file) {
|
||||
return file.endsWith(".csv");
|
||||
|
||||
}
|
||||
|
||||
// public boolean isCsv(String file) {
|
||||
// return file.endsWith(".csv");
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
|
||||
if(help) {
|
||||
CommandLine.usage(this.spec, System.out);
|
||||
}
|
||||
else {
|
||||
|
||||
ProgressBar bar = new ProgressBar();
|
||||
|
||||
//************* Progress Bar Prototype **************
|
||||
|
||||
System.out.println("\nReading pdf ...\n");
|
||||
// ProgressBar bar = new ProgressBar();
|
||||
//
|
||||
// System.out.println("\nReading pdf ...\n");
|
||||
//
|
||||
// bar.update(0, 1000);
|
||||
// for(int i=0;i<1000;i++) {
|
||||
// // do something!
|
||||
// for(int j=0;j<10000000;j++)
|
||||
// for(int p=0;p<10000000;p++);
|
||||
// // update the progress bar
|
||||
// bar.update(i, 1000);
|
||||
// }
|
||||
//
|
||||
// System.out.println("\nCopies correction succeed !\n");
|
||||
|
||||
bar.update(0, 1000);
|
||||
for(int i=0;i<1000;i++) {
|
||||
// do something!
|
||||
for(int j=0;j<10000000;j++)
|
||||
for(int p=0;p<10000000;p++);
|
||||
// update the progress bar
|
||||
bar.update(i, 1000);
|
||||
}
|
||||
|
||||
System.out.println("\nCopies correction succeed !\n");
|
||||
|
||||
|
||||
System.out.println("\nUpdate : "+step +"\n"+
|
||||
"Verbose : "+vb_level +"\n"+
|
||||
"Directory : "+directory_name +"\n"+
|
||||
"Result : "+result_name +"\n"+
|
||||
"Source : "+source_path +"\n");
|
||||
//***************************************************
|
||||
|
||||
|
||||
System.out.println("\nRead mode activated ...\n"); // Debug des paramètres à exploiter plus tard
|
||||
System.out.println("Update : "+step +"\n"+
|
||||
"Verbose : "+vb_level +"\n"+
|
||||
"Directory : "+directory_name +"\n"+
|
||||
"Result : "+result_name +"\n"+
|
||||
"Source : "+source_path +"\n");
|
||||
|
||||
|
||||
// ********VOIR EQUIPE********
|
||||
|
||||
// List imgList = PdfConvertor.toImage(directory_name); //retourne liste d'images
|
||||
//
|
||||
// CSV.setConfig(source_path);
|
||||
// Map resultMap = OCR.read(imgList); // retourne HMap nom - note par ex
|
||||
//
|
||||
// ExportCSV.createCSV(resultMap,result_name); // crée fichier csv selon HMAp avec le nom donné
|
||||
|
||||
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user