refactored to use a class for the argument parser

This commit is contained in:
Capelier-Marla 2022-12-12 23:07:35 +01:00
parent e2c82e24a3
commit a8f44010b8

View File

@ -1,33 +1,10 @@
package fr.packageviewer; package fr.packageviewer;
import com.beust.jcommander.JCommander;
public class Main { public class Main {
/* distribution the user want */
private static String distribution;
/**
* Get the command line argument given by the user, parse it with the parser and store it in the corresponding variable
* @author Capelier-Marla
* @param args the command line arguments given by the user
* @return void
*/
static void parseArguments(String[] args) {
// create JCommander and CommandLineParams objects
JCommander jCommander = new JCommander();
CommandLineParams params = new CommandLineParams();
// add argument required by the params to the JCommander object
jCommander.addObject(params);
// parse the argument from list of String
jCommander.parse(args);
// store the argument parsed in the variable
distribution = params.distribution;
}
public static void main(String[] args) { public static void main(String[] args) {
// send the command line arguments to the parser // send the command line arguments to the parser
parseArguments(args); ArgParse.parseArguments(args);
System.out.println(distribution); System.out.println(ArgParse.getDistribution());
} }
} }