Ajout du command parser v1
This commit is contained in:
parent
aff43ccdff
commit
9efed1893d
1
NGCC/.gitignore
vendored
Normal file
1
NGCC/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/bin/
|
51
NGCC/src/Exec.java
Normal file
51
NGCC/src/Exec.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
import commands.*;
|
||||||
|
import picocli.CommandLine;
|
||||||
|
|
||||||
|
public class Exec {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (args[0].contentEquals("-b") || args[0].contentEquals("--build")) {
|
||||||
|
CommandLine cmd = new CommandLine(new Build());
|
||||||
|
cmd.execute(args);
|
||||||
|
|
||||||
|
} else if (args[0].contentEquals("-r") || args[0].contentEquals("--read")) {
|
||||||
|
CommandLine cmd = new CommandLine(new Read());
|
||||||
|
cmd.execute(args);
|
||||||
|
|
||||||
|
} else if (args[0].contentEquals("-g") || args[0].contentEquals("--generate")) {
|
||||||
|
CommandLine cmd = new CommandLine(new Generate());
|
||||||
|
cmd.execute(args);
|
||||||
|
|
||||||
|
} else if (args[0].contentEquals("-p") || args[0].contentEquals("--produce")) {
|
||||||
|
CommandLine cmd = new CommandLine(new Produce());
|
||||||
|
cmd.execute(args);
|
||||||
|
|
||||||
|
} else if (args[0].contentEquals("-a") || args[0].contentEquals("--analyse")) {
|
||||||
|
CommandLine cmd = new CommandLine(new Analyse());
|
||||||
|
cmd.execute(args);
|
||||||
|
|
||||||
|
} else if (args[0].contentEquals("-e") || args[0].contentEquals("--evaluate")) {
|
||||||
|
CommandLine cmd = new CommandLine(new Evaluate());
|
||||||
|
cmd.execute(args);
|
||||||
|
|
||||||
|
} else if (args[0].contentEquals("--help")) {
|
||||||
|
CommandLine cmd = new CommandLine(new Help());
|
||||||
|
cmd.execute(args);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
System.out.println(args[0] + " : command not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
|
CommandLine cmd = new CommandLine(new Help());
|
||||||
|
System.out.println(cmd.execute(args));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
52
NGCC/src/commands/Analyse.java
Normal file
52
NGCC/src/commands/Analyse.java
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package commands;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
//import picocli.CommandLine;
|
||||||
|
import picocli.CommandLine.*;
|
||||||
|
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
name = "analyse",
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
public class Analyse implements Callable <Void> {
|
||||||
|
|
||||||
|
@Option(names= {"-a","--analyse"}, arity = "0", order = 1, description = "analyse mode")
|
||||||
|
boolean analyse;
|
||||||
|
|
||||||
|
@Option(names= {"-u"}, arity = "1", order = 2, description = "update mode")
|
||||||
|
int step;
|
||||||
|
|
||||||
|
@Option(names= {"-v"}, arity = "0..*", order = 3, defaultValue = "1", description ="verbose mode")
|
||||||
|
int vb_level;
|
||||||
|
|
||||||
|
@Option(names= {"-d"}, arity = "1", order = 4, defaultValue = "copies", description ="directory")
|
||||||
|
String directory;
|
||||||
|
|
||||||
|
@Parameters(arity = "0..1", defaultValue = "./source.txt", description ="source path")
|
||||||
|
String source_path;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
51
NGCC/src/commands/Build.java
Normal file
51
NGCC/src/commands/Build.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package commands;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
//import picocli.CommandLine;
|
||||||
|
import picocli.CommandLine.*;
|
||||||
|
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
name = "ngcc",
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
public class Build implements Callable <Void> {
|
||||||
|
|
||||||
|
@Option(names= {"-b","--build"}, arity = "0", order = 1, description = "build mode")
|
||||||
|
boolean build;
|
||||||
|
|
||||||
|
@Option(names= {"-u"}, arity = "1", order = 2, description = "update mode")
|
||||||
|
int step;
|
||||||
|
|
||||||
|
@Option(names= {"-v"}, arity = "0..1", defaultValue = "1", order = 3, description ="verbose mode")
|
||||||
|
int vb_level;
|
||||||
|
|
||||||
|
@Option(names= {"-a"}, arity = "1", order = 4, defaultValue = "answer-sheet.pdf", description ="answer")
|
||||||
|
String answer_name;
|
||||||
|
|
||||||
|
@Parameters(arity = "0..1", defaultValue = "./source.txt", description ="source path")
|
||||||
|
String source_path;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
63
NGCC/src/commands/Evaluate.java
Normal file
63
NGCC/src/commands/Evaluate.java
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
package commands;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
//import picocli.CommandLine;
|
||||||
|
import picocli.CommandLine.*;
|
||||||
|
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
name = "evaluate",
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
public class Evaluate implements Callable <Void> {
|
||||||
|
|
||||||
|
@Option(names= {"-e","--evaluate"}, arity = "0", order = 1, description = "evaluate mode")
|
||||||
|
boolean evaluate;
|
||||||
|
|
||||||
|
@Option(names= {"-u"}, arity = "1", order = 2, description = "update mode")
|
||||||
|
int step;
|
||||||
|
|
||||||
|
@Option(names= {"-v"}, arity = "0..*", order = 3, defaultValue = "1", description ="verbose mode")
|
||||||
|
int vb_level;
|
||||||
|
|
||||||
|
@Option(names= {"-o"}, arity = "1", order = 4, defaultValue = "result.csv", description ="result")
|
||||||
|
String result_name;
|
||||||
|
|
||||||
|
@Parameters(arity = "0..1", defaultValue = "./source.txt", description ="source path")
|
||||||
|
String source_path;
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isCsv(String file) {
|
||||||
|
return file.endsWith(".csv");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
67
NGCC/src/commands/Generate.java
Normal file
67
NGCC/src/commands/Generate.java
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
package commands;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
//import picocli.CommandLine;
|
||||||
|
import picocli.CommandLine.*;
|
||||||
|
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
name = "generate",
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
public class Generate implements Callable <Void> {
|
||||||
|
|
||||||
|
@Option(names= {"-g","--generate"}, arity = "0", order = 1, description = "generate mode")
|
||||||
|
boolean generate;
|
||||||
|
|
||||||
|
@Option(names= {"-u"}, arity = "1", order = 2, description = "update mode")
|
||||||
|
int step;
|
||||||
|
|
||||||
|
@Option(names= {"-v"}, arity = "0..*", order = 3, defaultValue = "1", description ="verbose mode")
|
||||||
|
int vb_level;
|
||||||
|
|
||||||
|
@Option(names= {"-t"}, arity = "1", order = 4, defaultValue = "topic-sheet.pdf", description ="topic")
|
||||||
|
String topic_name;
|
||||||
|
|
||||||
|
@Option(names= {"-a"}, arity = "1", order = 5, defaultValue = "answer-sheet.pdf", description ="answer")
|
||||||
|
String answer_name;
|
||||||
|
|
||||||
|
@Parameters(arity = "0..1", defaultValue = "./source.txt", description ="source path")
|
||||||
|
String source_path;
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isPdf(String file) {
|
||||||
|
return file.endsWith(".pdf");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
43
NGCC/src/commands/Help.java
Normal file
43
NGCC/src/commands/Help.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package commands;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
//import picocli.CommandLine;
|
||||||
|
import picocli.CommandLine.*;
|
||||||
|
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
name = "help",
|
||||||
|
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"}, required = true, arity = "0", order = 1, description = "help")
|
||||||
|
boolean help;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void call() throws Exception {
|
||||||
|
if(help) {
|
||||||
|
System.out.println("Commands List : -b, -r, -g, -p, -a, -e");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
63
NGCC/src/commands/Produce.java
Normal file
63
NGCC/src/commands/Produce.java
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
package commands;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
//import picocli.CommandLine;
|
||||||
|
import picocli.CommandLine.*;
|
||||||
|
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
name = "produce",
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
public class Produce implements Callable <Void> {
|
||||||
|
|
||||||
|
@Option(names= {"-p","--produce"}, arity = "0", order = 1, description = "produce mode")
|
||||||
|
boolean produce;
|
||||||
|
|
||||||
|
@Option(names= {"-u"}, arity = "1", order = 2, description = "update mode")
|
||||||
|
int step;
|
||||||
|
|
||||||
|
@Option(names= {"-v"}, arity = "0..*", order = 3, defaultValue = "1", description ="verbose mode")
|
||||||
|
int vb_level;
|
||||||
|
|
||||||
|
@Option(names= {"-c"}, arity = "1", order = 4, defaultValue = "corrected-sheet.pdf", description ="sheet")
|
||||||
|
String sheet_name;
|
||||||
|
|
||||||
|
@Parameters(arity = "0..1", defaultValue = "./source.txt", description ="source path")
|
||||||
|
String source_path;
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isPdf(String file) {
|
||||||
|
return file.endsWith(".pdf");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
66
NGCC/src/commands/Read.java
Normal file
66
NGCC/src/commands/Read.java
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package commands;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
//import picocli.CommandLine;
|
||||||
|
import picocli.CommandLine.*;
|
||||||
|
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
name = "read",
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
public class Read implements Callable <Void> {
|
||||||
|
|
||||||
|
@Option(names= {"-r","--read"}, arity = "0", order = 1, description = "read mode")
|
||||||
|
boolean read;
|
||||||
|
|
||||||
|
@Option(names= {"-u"}, arity = "1", order = 2, description = "update mode")
|
||||||
|
int step;
|
||||||
|
|
||||||
|
@Option(names= {"-v"}, arity = "0..*", order = 3, defaultValue = "1", description ="verbose mode")
|
||||||
|
int vb_level;
|
||||||
|
|
||||||
|
@Option(names= {"-d"}, arity = "1", order = 4, defaultValue = "copies", description ="directory")
|
||||||
|
String directory_name;
|
||||||
|
|
||||||
|
@Option(names= {"-o"}, arity = "1", order = 5, defaultValue = "result.csv", description ="result")
|
||||||
|
String result_name;
|
||||||
|
|
||||||
|
@Parameters(arity = "0..1", defaultValue = "./source.txt", description ="source path")
|
||||||
|
String source_path;
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isCsv(String file) {
|
||||||
|
return file.endsWith(".csv");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void call() throws Exception {
|
||||||
|
if(read) {
|
||||||
|
System.out.println("Read mode activated ...");
|
||||||
|
System.out.println("Update : "+step);
|
||||||
|
System.out.println("Verbose : "+vb_level);
|
||||||
|
System.out.println("Directory : "+directory_name);
|
||||||
|
|
||||||
|
if (isCsv(result_name)) {
|
||||||
|
System.out.println("Result : "+result_name);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("The specified for the result file is invalid");
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Source : "+source_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
15165
NGCC/src/picocli/CommandLine.java
Normal file
15165
NGCC/src/picocli/CommandLine.java
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user