refactored to use a class for the argument parser
This commit is contained in:
		
							parent
							
								
									e2c82e24a3
								
							
						
					
					
						commit
						a8f44010b8
					
				@ -1,33 +1,10 @@
 | 
			
		||||
package fr.packageviewer;
 | 
			
		||||
 | 
			
		||||
import com.beust.jcommander.JCommander;
 | 
			
		||||
 | 
			
		||||
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) {
 | 
			
		||||
		// send the command line arguments to the parser
 | 
			
		||||
		parseArguments(args);
 | 
			
		||||
		System.out.println(distribution);
 | 
			
		||||
		ArgParse.parseArguments(args);
 | 
			
		||||
		System.out.println(ArgParse.getDistribution());
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user