M332-PT-NGCC/NGCC/src/Exec.java

69 lines
2.3 KiB
Java
Raw Normal View History

2019-10-04 13:34:50 +02:00
2019-09-27 00:32:16 +02:00
import java.util.concurrent.Callable;
2019-09-17 13:34:02 +02:00
import commands.Analyse;
import commands.Build;
import commands.Evaluate;
import commands.Generate;
import commands.Produce;
2019-09-15 12:27:15 +02:00
import commands.Read;
2019-09-10 21:42:03 +02:00
import picocli.CommandLine;
2019-09-15 12:27:15 +02:00
import picocli.CommandLine.*;
@Command(
name = "Exec",
version = "Version 1.0",
sortOptions = false,
usageHelpWidth = 60,
header = "\n ---- Nicely Generated and Corrected Copies ---- \n\n" +
" _______ _________________ ________ \n" +
" \\ \\ / _____/\\_ ___ \\\\_ ___ \\ \n" +
" / | \\/ \\ ___/ \\ \\// \\ \\/ \n" +
" / | \\ \\_ \\ \\ \\___\\ \\___ \n" +
" \\____|__ /\\______ /\\______ /\\______ / \n" +
" \\/ \\/ \\/ \\/ \n" +
" \n" ,
footer = "\n\n ---- Provided by IUT Info Nice S3T-G4 ---- \n",
2019-09-17 13:34:02 +02:00
description = ""
2019-09-15 12:27:15 +02:00
)
public class Exec implements Callable <Void> {
2019-09-17 13:34:02 +02:00
@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)
2019-09-15 12:27:15 +02:00
2019-09-26 21:38:13 +02:00
2019-09-15 12:27:15 +02:00
public static void main(String[] args) throws InterruptedException {
2019-09-17 13:34:02 +02:00
// Système de subcommand semblable à celui de git permettant d'appeler les classes relatives
2019-10-04 10:49:13 +02:00
String[] t = {"-r","-v9","-d","pdf","config.txt"};
2019-09-15 12:27:15 +02:00
CommandLine cmd = new CommandLine (new Exec())
2019-09-17 13:34:02 +02:00
.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
2019-09-15 12:27:15 +02:00
2019-10-04 10:49:13 +02:00
cmd.execute(t); //t
2019-09-15 12:27:15 +02:00
2019-09-10 21:42:03 +02:00
}
2019-09-26 21:38:13 +02:00
2019-09-10 21:42:03 +02:00
2019-09-15 12:27:15 +02:00
@Override
public Void call() throws Exception {
2019-09-17 13:34:02 +02:00
CommandLine.usage(this.spec, System.out); // Retourne l'aide générée par l'API s'il n'y a pas d'arguments
2019-09-15 12:27:15 +02:00
return null;
}
2019-09-10 21:42:03 +02:00
}